Skip to content

Commit 85411d1

Browse files
Michael RieschHans Verkuil
authored andcommitted
media: rockchip: rkcif: add abstraction for interface and crop blocks
Add an abstraction for the INTERFACE and CROP parts of the different Rockchip Camera Interface (CIF) variants. These parts are represented as V4L2 subdevice with one sink pad and one source pad. The sink pad is connected to a subdevice: either the subdevice provided by the driver of the companion chip connected to the DVP, or the subdevice provided by the MIPI CSI-2 receiver. The source pad is connected to V4l2 device(s) provided by one or many instance(s) of the DMA abstraction. Tested-by: Gerald Loacker <gerald.loacker@wolfvision.net> Reviewed-by: Gerald Loacker <gerald.loacker@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>
1 parent f53fb31 commit 85411d1

5 files changed

Lines changed: 521 additions & 0 deletions

File tree

drivers/media/platform/rockchip/rkcif/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
obj-$(CONFIG_VIDEO_ROCKCHIP_CIF) += rockchip-cif.o
33

44
rockchip-cif-objs += rkcif-dev.o
5+
rockchip-cif-objs += rkcif-interface.o

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

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,78 @@
2727
#define RKCIF_DRIVER_NAME "rockchip-cif"
2828
#define RKCIF_CLK_MAX 4
2929

30+
enum rkcif_format_type {
31+
RKCIF_FMT_TYPE_INVALID,
32+
RKCIF_FMT_TYPE_YUV,
33+
RKCIF_FMT_TYPE_RAW,
34+
};
35+
36+
enum rkcif_interface_index {
37+
RKCIF_DVP,
38+
RKCIF_MIPI_BASE,
39+
RKCIF_MIPI1 = RKCIF_MIPI_BASE,
40+
RKCIF_MIPI2,
41+
RKCIF_MIPI3,
42+
RKCIF_MIPI4,
43+
RKCIF_MIPI5,
44+
RKCIF_MIPI6,
45+
RKCIF_MIPI_MAX,
46+
RKCIF_IF_MAX = RKCIF_MIPI_MAX
47+
};
48+
49+
enum rkcif_interface_pad_index {
50+
RKCIF_IF_PAD_SINK,
51+
RKCIF_IF_PAD_SRC,
52+
RKCIF_IF_PAD_MAX
53+
};
54+
55+
enum rkcif_interface_status {
56+
RKCIF_IF_INACTIVE,
57+
RKCIF_IF_ACTIVE,
58+
};
59+
60+
enum rkcif_interface_type {
61+
RKCIF_IF_INVALID,
62+
RKCIF_IF_DVP,
63+
RKCIF_IF_MIPI,
64+
};
65+
66+
struct rkcif_input_fmt {
67+
u32 mbus_code;
68+
69+
enum rkcif_format_type fmt_type;
70+
enum v4l2_field field;
71+
};
72+
73+
struct rkcif_interface;
74+
3075
struct rkcif_remote {
3176
struct v4l2_async_connection async_conn;
3277
struct v4l2_subdev *sd;
78+
79+
struct rkcif_interface *interface;
80+
};
81+
82+
struct rkcif_dvp {
83+
u32 dvp_clk_delay;
84+
};
85+
86+
struct rkcif_interface {
87+
enum rkcif_interface_type type;
88+
enum rkcif_interface_status status;
89+
enum rkcif_interface_index index;
90+
struct rkcif_device *rkcif;
91+
struct rkcif_remote *remote;
92+
const struct rkcif_input_fmt *in_fmts;
93+
unsigned int in_fmts_num;
94+
95+
struct media_pad pads[RKCIF_IF_PAD_MAX];
96+
struct v4l2_fwnode_endpoint vep;
97+
struct v4l2_subdev sd;
98+
99+
union {
100+
struct rkcif_dvp dvp;
101+
};
33102
};
34103

35104
struct rkcif_match_data {
@@ -47,6 +116,8 @@ struct rkcif_device {
47116
struct reset_control *reset;
48117
void __iomem *base_addr;
49118

119+
struct rkcif_interface interfaces[RKCIF_IF_MAX];
120+
50121
struct media_device media_dev;
51122
struct v4l2_device v4l2_dev;
52123
struct v4l2_async_notifier notifier;

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,21 @@ static int rkcif_notifier_bound(struct v4l2_async_notifier *notifier,
7474
struct v4l2_subdev *sd,
7575
struct v4l2_async_connection *asd)
7676
{
77+
struct rkcif_device *rkcif =
78+
container_of(notifier, struct rkcif_device, notifier);
7779
struct rkcif_remote *remote =
7880
container_of(asd, struct rkcif_remote, async_conn);
81+
struct media_pad *sink_pad =
82+
&remote->interface->pads[RKCIF_IF_PAD_SINK];
83+
int ret;
84+
85+
ret = v4l2_create_fwnode_links_to_pad(sd, sink_pad,
86+
MEDIA_LNK_FL_ENABLED);
87+
if (ret) {
88+
dev_err(rkcif->dev, "failed to link source pad of %s\n",
89+
sd->name);
90+
return ret;
91+
}
7992

8093
remote->sd = sd;
8194

0 commit comments

Comments
 (0)