Commit e472d6a2 authored by Dafna Hirschfeld's avatar Dafna Hirschfeld Committed by Mauro Carvalho Chehab

media: vimc: add vimc_ent_type struct for the callbacks of entities

Since each vimc entity type is defined by the
callbacks implementation, it is a good idea to
add a struct to hold these callbacks.

Each vimc entity then declare its type in the file for
the entity.
Signed-off-by: default avatarDafna Hirschfeld <dafna.hirschfeld@collabora.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 5aa0d096
...@@ -325,7 +325,7 @@ static const struct media_entity_operations vimc_cap_mops = { ...@@ -325,7 +325,7 @@ static const struct media_entity_operations vimc_cap_mops = {
.link_validate = vimc_vdev_link_validate, .link_validate = vimc_vdev_link_validate,
}; };
void vimc_cap_release(struct vimc_ent_device *ved) static void vimc_cap_release(struct vimc_ent_device *ved)
{ {
struct vimc_cap_device *vcap = struct vimc_cap_device *vcap =
container_of(ved, struct vimc_cap_device, ved); container_of(ved, struct vimc_cap_device, ved);
...@@ -334,7 +334,7 @@ void vimc_cap_release(struct vimc_ent_device *ved) ...@@ -334,7 +334,7 @@ void vimc_cap_release(struct vimc_ent_device *ved)
kfree(vcap); kfree(vcap);
} }
void vimc_cap_unregister(struct vimc_ent_device *ved) static void vimc_cap_unregister(struct vimc_ent_device *ved)
{ {
struct vimc_cap_device *vcap = struct vimc_cap_device *vcap =
container_of(ved, struct vimc_cap_device, ved); container_of(ved, struct vimc_cap_device, ved);
...@@ -382,8 +382,8 @@ static void *vimc_cap_process_frame(struct vimc_ent_device *ved, ...@@ -382,8 +382,8 @@ static void *vimc_cap_process_frame(struct vimc_ent_device *ved,
return NULL; return NULL;
} }
struct vimc_ent_device *vimc_cap_add(struct vimc_device *vimc, static struct vimc_ent_device *vimc_cap_add(struct vimc_device *vimc,
const char *vcfg_name) const char *vcfg_name)
{ {
struct v4l2_device *v4l2_dev = &vimc->v4l2_dev; struct v4l2_device *v4l2_dev = &vimc->v4l2_dev;
const struct vimc_pix_map *vpix; const struct vimc_pix_map *vpix;
...@@ -478,3 +478,9 @@ struct vimc_ent_device *vimc_cap_add(struct vimc_device *vimc, ...@@ -478,3 +478,9 @@ struct vimc_ent_device *vimc_cap_add(struct vimc_device *vimc,
return ERR_PTR(ret); return ERR_PTR(ret);
} }
struct vimc_ent_type vimc_cap_type = {
.add = vimc_cap_add,
.unregister = vimc_cap_unregister,
.release = vimc_cap_release
};
...@@ -120,24 +120,35 @@ struct vimc_device { ...@@ -120,24 +120,35 @@ struct vimc_device {
}; };
/** /**
* struct vimc_ent_config Structure which describes individual * struct vimc_ent_type Structure for the callbacks of the entity types
* configuration for each entity *
* *
* @name entity name
* @add initializes and registers * @add initializes and registers
* vimc entity - called from vimc-core * vimc entity - called from vimc-core
* @unregister unregisters vimc entity - called from vimc-core * @unregister unregisters vimc entity - called from vimc-core
* @release releases vimc entity - called from the v4l2_dev * @release releases vimc entity - called from the v4l2_dev
* release callback * release callback
*/ */
struct vimc_ent_config { struct vimc_ent_type {
const char *name;
struct vimc_ent_device *(*add)(struct vimc_device *vimc, struct vimc_ent_device *(*add)(struct vimc_device *vimc,
const char *vcfg_name); const char *vcfg_name);
void (*unregister)(struct vimc_ent_device *ved); void (*unregister)(struct vimc_ent_device *ved);
void (*release)(struct vimc_ent_device *ved); void (*release)(struct vimc_ent_device *ved);
}; };
/**
* struct vimc_ent_config Structure which describes individual
* configuration for each entity
*
* @name entity name
* @type contain the callbacks of this entity type
*
*/
struct vimc_ent_config {
const char *name;
struct vimc_ent_type *type;
};
/** /**
* vimc_is_source - returns true if the entity has only source pads * vimc_is_source - returns true if the entity has only source pads
* *
...@@ -146,23 +157,10 @@ struct vimc_ent_config { ...@@ -146,23 +157,10 @@ struct vimc_ent_config {
*/ */
bool vimc_is_source(struct media_entity *ent); bool vimc_is_source(struct media_entity *ent);
/* prototypes for vimc_ent_config hooks */ extern struct vimc_ent_type vimc_sen_type;
struct vimc_ent_device *vimc_cap_add(struct vimc_device *vimc, extern struct vimc_ent_type vimc_deb_type;
const char *vcfg_name); extern struct vimc_ent_type vimc_sca_type;
void vimc_cap_unregister(struct vimc_ent_device *ved); extern struct vimc_ent_type vimc_cap_type;
void vimc_cap_release(struct vimc_ent_device *ved);
struct vimc_ent_device *vimc_deb_add(struct vimc_device *vimc,
const char *vcfg_name);
void vimc_deb_release(struct vimc_ent_device *ved);
struct vimc_ent_device *vimc_sca_add(struct vimc_device *vimc,
const char *vcfg_name);
void vimc_sca_release(struct vimc_ent_device *ved);
struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc,
const char *vcfg_name);
void vimc_sen_release(struct vimc_ent_device *ved);
/** /**
* vimc_pix_map_by_index - get vimc_pix_map struct by its index * vimc_pix_map_by_index - get vimc_pix_map struct by its index
......
...@@ -47,52 +47,40 @@ struct vimc_pipeline_config { ...@@ -47,52 +47,40 @@ struct vimc_pipeline_config {
static struct vimc_ent_config ent_config[] = { static struct vimc_ent_config ent_config[] = {
{ {
.name = "Sensor A", .name = "Sensor A",
.add = vimc_sen_add, .type = &vimc_sen_type
.release = vimc_sen_release,
}, },
{ {
.name = "Sensor B", .name = "Sensor B",
.add = vimc_sen_add, .type = &vimc_sen_type
.release = vimc_sen_release,
}, },
{ {
.name = "Debayer A", .name = "Debayer A",
.add = vimc_deb_add, .type = &vimc_deb_type
.release = vimc_deb_release,
}, },
{ {
.name = "Debayer B", .name = "Debayer B",
.add = vimc_deb_add, .type = &vimc_deb_type
.release = vimc_deb_release,
}, },
{ {
.name = "Raw Capture 0", .name = "Raw Capture 0",
.add = vimc_cap_add, .type = &vimc_cap_type
.unregister = vimc_cap_unregister,
.release = vimc_cap_release,
}, },
{ {
.name = "Raw Capture 1", .name = "Raw Capture 1",
.add = vimc_cap_add, .type = &vimc_cap_type
.unregister = vimc_cap_unregister,
.release = vimc_cap_release,
}, },
{ {
/* TODO: change this to vimc-input when it is implemented */ /* TODO: change this to vimc-input when it is implemented */
.name = "RGB/YUV Input", .name = "RGB/YUV Input",
.add = vimc_sen_add, .type = &vimc_sen_type
.release = vimc_sen_release,
}, },
{ {
.name = "Scaler", .name = "Scaler",
.add = vimc_sca_add, .type = &vimc_sca_type
.release = vimc_sca_release,
}, },
{ {
.name = "RGB/YUV Capture", .name = "RGB/YUV Capture",
.add = vimc_cap_add, .type = &vimc_cap_type
.unregister = vimc_cap_unregister,
.release = vimc_cap_release,
}, },
}; };
...@@ -166,7 +154,7 @@ static void vimc_release_subdevs(struct vimc_device *vimc) ...@@ -166,7 +154,7 @@ static void vimc_release_subdevs(struct vimc_device *vimc)
for (i = 0; i < vimc->pipe_cfg->num_ents; i++) for (i = 0; i < vimc->pipe_cfg->num_ents; i++)
if (vimc->ent_devs[i]) if (vimc->ent_devs[i])
vimc->pipe_cfg->ents[i].release(vimc->ent_devs[i]); vimc->pipe_cfg->ents[i].type->release(vimc->ent_devs[i]);
} }
static void vimc_unregister_subdevs(struct vimc_device *vimc) static void vimc_unregister_subdevs(struct vimc_device *vimc)
...@@ -174,8 +162,8 @@ static void vimc_unregister_subdevs(struct vimc_device *vimc) ...@@ -174,8 +162,8 @@ static void vimc_unregister_subdevs(struct vimc_device *vimc)
unsigned int i; unsigned int i;
for (i = 0; i < vimc->pipe_cfg->num_ents; i++) for (i = 0; i < vimc->pipe_cfg->num_ents; i++)
if (vimc->ent_devs[i] && vimc->pipe_cfg->ents[i].unregister) if (vimc->ent_devs[i] && vimc->pipe_cfg->ents[i].type->unregister)
vimc->pipe_cfg->ents[i].unregister(vimc->ent_devs[i]); vimc->pipe_cfg->ents[i].type->unregister(vimc->ent_devs[i]);
} }
static int vimc_add_subdevs(struct vimc_device *vimc) static int vimc_add_subdevs(struct vimc_device *vimc)
...@@ -185,7 +173,7 @@ static int vimc_add_subdevs(struct vimc_device *vimc) ...@@ -185,7 +173,7 @@ static int vimc_add_subdevs(struct vimc_device *vimc)
for (i = 0; i < vimc->pipe_cfg->num_ents; i++) { for (i = 0; i < vimc->pipe_cfg->num_ents; i++) {
dev_dbg(vimc->mdev.dev, "new entity for %s\n", dev_dbg(vimc->mdev.dev, "new entity for %s\n",
vimc->pipe_cfg->ents[i].name); vimc->pipe_cfg->ents[i].name);
vimc->ent_devs[i] = vimc->pipe_cfg->ents[i].add(vimc, vimc->ent_devs[i] = vimc->pipe_cfg->ents[i].type->add(vimc,
vimc->pipe_cfg->ents[i].name); vimc->pipe_cfg->ents[i].name);
if (IS_ERR(vimc->ent_devs[i])) { if (IS_ERR(vimc->ent_devs[i])) {
int err = PTR_ERR(vimc->ent_devs[i]); int err = PTR_ERR(vimc->ent_devs[i]);
......
...@@ -494,7 +494,7 @@ static const struct v4l2_ctrl_ops vimc_deb_ctrl_ops = { ...@@ -494,7 +494,7 @@ static const struct v4l2_ctrl_ops vimc_deb_ctrl_ops = {
.s_ctrl = vimc_deb_s_ctrl, .s_ctrl = vimc_deb_s_ctrl,
}; };
void vimc_deb_release(struct vimc_ent_device *ved) static void vimc_deb_release(struct vimc_ent_device *ved)
{ {
struct vimc_deb_device *vdeb = struct vimc_deb_device *vdeb =
container_of(ved, struct vimc_deb_device, ved); container_of(ved, struct vimc_deb_device, ved);
...@@ -522,8 +522,8 @@ static const struct v4l2_ctrl_config vimc_deb_ctrl_mean_win_size = { ...@@ -522,8 +522,8 @@ static const struct v4l2_ctrl_config vimc_deb_ctrl_mean_win_size = {
.def = 3, .def = 3,
}; };
struct vimc_ent_device *vimc_deb_add(struct vimc_device *vimc, static struct vimc_ent_device *vimc_deb_add(struct vimc_device *vimc,
const char *vcfg_name) const char *vcfg_name)
{ {
struct v4l2_device *v4l2_dev = &vimc->v4l2_dev; struct v4l2_device *v4l2_dev = &vimc->v4l2_dev;
struct vimc_deb_device *vdeb; struct vimc_deb_device *vdeb;
...@@ -579,3 +579,8 @@ struct vimc_ent_device *vimc_deb_add(struct vimc_device *vimc, ...@@ -579,3 +579,8 @@ struct vimc_ent_device *vimc_deb_add(struct vimc_device *vimc,
return ERR_PTR(ret); return ERR_PTR(ret);
} }
struct vimc_ent_type vimc_deb_type = {
.add = vimc_deb_add,
.release = vimc_deb_release
};
...@@ -464,7 +464,7 @@ static void *vimc_sca_process_frame(struct vimc_ent_device *ved, ...@@ -464,7 +464,7 @@ static void *vimc_sca_process_frame(struct vimc_ent_device *ved,
return vsca->src_frame; return vsca->src_frame;
}; };
void vimc_sca_release(struct vimc_ent_device *ved) static void vimc_sca_release(struct vimc_ent_device *ved)
{ {
struct vimc_sca_device *vsca = struct vimc_sca_device *vsca =
container_of(ved, struct vimc_sca_device, ved); container_of(ved, struct vimc_sca_device, ved);
...@@ -473,8 +473,8 @@ void vimc_sca_release(struct vimc_ent_device *ved) ...@@ -473,8 +473,8 @@ void vimc_sca_release(struct vimc_ent_device *ved)
kfree(vsca); kfree(vsca);
} }
struct vimc_ent_device *vimc_sca_add(struct vimc_device *vimc, static struct vimc_ent_device *vimc_sca_add(struct vimc_device *vimc,
const char *vcfg_name) const char *vcfg_name)
{ {
struct v4l2_device *v4l2_dev = &vimc->v4l2_dev; struct v4l2_device *v4l2_dev = &vimc->v4l2_dev;
struct vimc_sca_device *vsca; struct vimc_sca_device *vsca;
...@@ -509,3 +509,8 @@ struct vimc_ent_device *vimc_sca_add(struct vimc_device *vimc, ...@@ -509,3 +509,8 @@ struct vimc_ent_device *vimc_sca_add(struct vimc_device *vimc,
return &vsca->ved; return &vsca->ved;
} }
struct vimc_ent_type vimc_sca_type = {
.add = vimc_sca_add,
.release = vimc_sca_release
};
...@@ -279,7 +279,7 @@ static const struct v4l2_ctrl_ops vimc_sen_ctrl_ops = { ...@@ -279,7 +279,7 @@ static const struct v4l2_ctrl_ops vimc_sen_ctrl_ops = {
.s_ctrl = vimc_sen_s_ctrl, .s_ctrl = vimc_sen_s_ctrl,
}; };
void vimc_sen_release(struct vimc_ent_device *ved) static void vimc_sen_release(struct vimc_ent_device *ved)
{ {
struct vimc_sen_device *vsen = struct vimc_sen_device *vsen =
container_of(ved, struct vimc_sen_device, ved); container_of(ved, struct vimc_sen_device, ved);
...@@ -307,8 +307,8 @@ static const struct v4l2_ctrl_config vimc_sen_ctrl_test_pattern = { ...@@ -307,8 +307,8 @@ static const struct v4l2_ctrl_config vimc_sen_ctrl_test_pattern = {
.qmenu = tpg_pattern_strings, .qmenu = tpg_pattern_strings,
}; };
struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc, static struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc,
const char *vcfg_name) const char *vcfg_name)
{ {
struct v4l2_device *v4l2_dev = &vimc->v4l2_dev; struct v4l2_device *v4l2_dev = &vimc->v4l2_dev;
struct vimc_sen_device *vsen; struct vimc_sen_device *vsen;
...@@ -374,3 +374,8 @@ struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc, ...@@ -374,3 +374,8 @@ struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc,
return ERR_PTR(ret); return ERR_PTR(ret);
} }
struct vimc_ent_type vimc_sen_type = {
.add = vimc_sen_add,
.release = vimc_sen_release
};
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