In preparation of need for sharing of data between subdevices,
make the struct dcmipp_device structure part of dcmipp_common.h
and share it with subdevs at init time. This allows for simplifying
parameters of each subdev init function as well.
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
---
.../st/stm32/stm32-dcmipp/dcmipp-bytecap.c | 13 ++++---
.../st/stm32/stm32-dcmipp/dcmipp-byteproc.c | 11 +++---
.../platform/st/stm32/stm32-dcmipp/dcmipp-common.h | 43 +++++++++++++++++-----
.../platform/st/stm32/stm32-dcmipp/dcmipp-core.c | 33 ++---------------
.../platform/st/stm32/stm32-dcmipp/dcmipp-input.c | 12 +++---
5 files changed, 55 insertions(+), 57 deletions(-)
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-bytecap.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-bytecap.c
index 19e6b187be22..f4b962867dc2 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-bytecap.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-bytecap.c
@@ -855,12 +855,11 @@ static const struct media_entity_operations dcmipp_bytecap_entity_ops = {
.link_validate = dcmipp_bytecap_link_validate,
};
-struct dcmipp_ent_device *dcmipp_bytecap_ent_init(struct device *dev,
- const char *entity_name,
- struct v4l2_device *v4l2_dev,
- void __iomem *regs)
+struct dcmipp_ent_device *dcmipp_bytecap_ent_init(const char *entity_name,
+ struct dcmipp_device *dcmipp)
{
struct dcmipp_bytecap_device *vcap;
+ struct device *dev = dcmipp->dev;
struct video_device *vdev;
struct vb2_queue *q;
const unsigned long pad_flag = MEDIA_PAD_FL_SINK;
@@ -878,6 +877,8 @@ struct dcmipp_ent_device *dcmipp_bytecap_ent_init(struct device *dev,
goto err_free_vcap;
}
+ vcap->ved.dcmipp = dcmipp;
+
/* Initialize the media entity */
vcap->vdev.entity.name = entity_name;
vcap->vdev.entity.function = MEDIA_ENT_F_IO_V4L;
@@ -928,7 +929,7 @@ struct dcmipp_ent_device *dcmipp_bytecap_ent_init(struct device *dev,
vcap->ved.handler = dcmipp_bytecap_irq_callback;
vcap->ved.thread_fn = dcmipp_bytecap_irq_thread;
vcap->dev = dev;
- vcap->regs = regs;
+ vcap->regs = dcmipp->regs;
/* Initialize the video_device struct */
vdev = &vcap->vdev;
@@ -939,7 +940,7 @@ struct dcmipp_ent_device *dcmipp_bytecap_ent_init(struct device *dev,
vdev->ioctl_ops = &dcmipp_bytecap_ioctl_ops;
vdev->lock = &vcap->lock;
vdev->queue = q;
- vdev->v4l2_dev = v4l2_dev;
+ vdev->v4l2_dev = &dcmipp->v4l2_dev;
strscpy(vdev->name, entity_name, sizeof(vdev->name));
video_set_drvdata(vdev, &vcap->ved);
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-byteproc.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-byteproc.c
index f9e4a3a9ef3f..aa0561957b80 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-byteproc.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-byteproc.c
@@ -571,8 +571,8 @@ void dcmipp_byteproc_ent_release(struct dcmipp_ent_device *ved)
}
struct dcmipp_ent_device *
-dcmipp_byteproc_ent_init(struct device *dev, const char *entity_name,
- struct v4l2_device *v4l2_dev, void __iomem *regs)
+dcmipp_byteproc_ent_init(const char *entity_name,
+ struct dcmipp_device *dcmipp)
{
struct dcmipp_byteproc_device *byteproc;
const unsigned long pads_flag[] = {
@@ -585,11 +585,11 @@ dcmipp_byteproc_ent_init(struct device *dev, const char *entity_name,
if (!byteproc)
return ERR_PTR(-ENOMEM);
- byteproc->regs = regs;
+ byteproc->regs = dcmipp->regs;
/* Initialize ved and sd */
ret = dcmipp_ent_sd_register(&byteproc->ved, &byteproc->sd,
- v4l2_dev, entity_name,
+ &dcmipp->v4l2_dev, entity_name,
MEDIA_ENT_F_PROC_VIDEO_SCALER,
ARRAY_SIZE(pads_flag), pads_flag,
&dcmipp_byteproc_int_ops,
@@ -600,7 +600,8 @@ dcmipp_byteproc_ent_init(struct device *dev, const char *entity_name,
return ERR_PTR(ret);
}
- byteproc->dev = dev;
+ byteproc->ved.dcmipp = dcmipp;
+ byteproc->dev = dcmipp->dev;
return &byteproc->ved;
}
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
index fe5f97233f5e..e5c0eda8b18a 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-common.h
@@ -58,10 +58,36 @@ do { \
(fmt)->xfer_func = DCMIPP_XFER_FUNC_DEFAULT; \
} while (0)
+struct dcmipp_device {
+ /* The platform device */
+ struct platform_device pdev;
+ struct device *dev;
+
+ /* Hardware resources */
+ void __iomem *regs;
+ struct clk *mclk;
+ struct clk *kclk;
+
+ /* The pipeline configuration */
+ const struct dcmipp_pipeline_config *pipe_cfg;
+
+ /* The Associated media_device parent */
+ struct media_device mdev;
+
+ /* Internal v4l2 parent device*/
+ struct v4l2_device v4l2_dev;
+
+ /* Entities */
+ struct dcmipp_ent_device **entity;
+
+ struct v4l2_async_notifier notifier;
+};
+
/**
* struct dcmipp_ent_device - core struct that represents a node in the topology
*
* @ent: the pointer to struct media_entity for the node
+ * @dcmipp: the pointer to the parent dcmipp_device
* @pads: the list of pads of the node
* @bus: struct v4l2_mbus_config_parallel describing input bus
* @bus_type: type of input bus (parallel or BT656)
@@ -84,6 +110,7 @@ do { \
*/
struct dcmipp_ent_device {
struct media_entity *ent;
+ struct dcmipp_device *dcmipp;
struct media_pad *pads;
/* Parallel input device */
@@ -199,19 +226,15 @@ static inline void __reg_clear(struct device *dev, void __iomem *base, u32 reg,
}
/* DCMIPP subdev init / release entry points */
-struct dcmipp_ent_device *dcmipp_inp_ent_init(struct device *dev,
- const char *entity_name,
- struct v4l2_device *v4l2_dev,
- void __iomem *regs);
+struct dcmipp_ent_device *dcmipp_inp_ent_init(const char *entity_name,
+ struct dcmipp_device *dcmipp);
void dcmipp_inp_ent_release(struct dcmipp_ent_device *ved);
struct dcmipp_ent_device *
-dcmipp_byteproc_ent_init(struct device *dev, const char *entity_name,
- struct v4l2_device *v4l2_dev, void __iomem *regs);
+dcmipp_byteproc_ent_init(const char *entity_name,
+ struct dcmipp_device *dcmipp);
void dcmipp_byteproc_ent_release(struct dcmipp_ent_device *ved);
-struct dcmipp_ent_device *dcmipp_bytecap_ent_init(struct device *dev,
- const char *entity_name,
- struct v4l2_device *v4l2_dev,
- void __iomem *regs);
+struct dcmipp_ent_device *dcmipp_bytecap_ent_init(const char *entity_name,
+ struct dcmipp_device *dcmipp);
void dcmipp_bytecap_ent_release(struct dcmipp_ent_device *ved);
#endif
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c
index 49398d077764..dd784cfcaac8 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-core.c
@@ -33,31 +33,6 @@
.flags = link_flags, \
}
-struct dcmipp_device {
- /* The platform device */
- struct platform_device pdev;
- struct device *dev;
-
- /* Hardware resources */
- void __iomem *regs;
- struct clk *mclk;
- struct clk *kclk;
-
- /* The pipeline configuration */
- const struct dcmipp_pipeline_config *pipe_cfg;
-
- /* The Associated media_device parent */
- struct media_device mdev;
-
- /* Internal v4l2 parent device*/
- struct v4l2_device v4l2_dev;
-
- /* Entities */
- struct dcmipp_ent_device **entity;
-
- struct v4l2_async_notifier notifier;
-};
-
static inline struct dcmipp_device *
notifier_to_dcmipp(struct v4l2_async_notifier *n)
{
@@ -68,8 +43,8 @@ notifier_to_dcmipp(struct v4l2_async_notifier *n)
struct dcmipp_ent_config {
const char *name;
struct dcmipp_ent_device *(*init)
- (struct device *dev, const char *entity_name,
- struct v4l2_device *v4l2_dev, void __iomem *regs);
+ (const char *entity_name,
+ struct dcmipp_device *dcmipp);
void (*release)(struct dcmipp_ent_device *ved);
};
@@ -221,9 +196,7 @@ static int dcmipp_create_subdevs(struct dcmipp_device *dcmipp)
dev_dbg(dcmipp->dev, "add subdev %s\n", name);
dcmipp->entity[i] =
- dcmipp->pipe_cfg->ents[i].init(dcmipp->dev, name,
- &dcmipp->v4l2_dev,
- dcmipp->regs);
+ dcmipp->pipe_cfg->ents[i].init(name, dcmipp);
if (IS_ERR(dcmipp->entity[i])) {
dev_err(dcmipp->dev, "failed to init subdev %s\n",
name);
diff --git a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-input.c b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-input.c
index c4bc76909b1c..597f88ac7915 100644
--- a/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-input.c
+++ b/drivers/media/platform/st/stm32/stm32-dcmipp/dcmipp-input.c
@@ -515,15 +515,14 @@ void dcmipp_inp_ent_release(struct dcmipp_ent_device *ved)
dcmipp_ent_sd_unregister(ved, &inp->sd);
}
-struct dcmipp_ent_device *dcmipp_inp_ent_init(struct device *dev,
- const char *entity_name,
- struct v4l2_device *v4l2_dev,
- void __iomem *regs)
+struct dcmipp_ent_device *dcmipp_inp_ent_init(const char *entity_name,
+ struct dcmipp_device *dcmipp)
{
struct dcmipp_inp_device *inp;
const unsigned long pads_flag[] = {
MEDIA_PAD_FL_SINK, MEDIA_PAD_FL_SOURCE,
};
+ struct device *dev = dcmipp->dev;
int ret;
/* Allocate the inp struct */
@@ -531,10 +530,10 @@ struct dcmipp_ent_device *dcmipp_inp_ent_init(struct device *dev,
if (!inp)
return ERR_PTR(-ENOMEM);
- inp->regs = regs;
+ inp->regs = dcmipp->regs;
/* Initialize ved and sd */
- ret = dcmipp_ent_sd_register(&inp->ved, &inp->sd, v4l2_dev,
+ ret = dcmipp_ent_sd_register(&inp->ved, &inp->sd, &dcmipp->v4l2_dev,
entity_name, MEDIA_ENT_F_VID_IF_BRIDGE,
ARRAY_SIZE(pads_flag), pads_flag,
&dcmipp_inp_int_ops, &dcmipp_inp_ops,
@@ -543,6 +542,7 @@ struct dcmipp_ent_device *dcmipp_inp_ent_init(struct device *dev,
kfree(inp);
return ERR_PTR(ret);
}
+ inp->ved.dcmipp = dcmipp;
inp->dev = dev;
--
2.34.1
© 2016 - 2026 Red Hat, Inc.