mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-09 06:43:09 +00:00
media: qcom: camss: Decompose register and link operations
Split link and register operations. Add dedicated link callback according to SoC identifier. Signed-off-by: Atanas Filipov <quic_afilipov@quicinc.com> Signed-off-by: Gjorgji Rosikopulos <quic_grosikop@quicinc.com> Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> # sc8280xp/sm8250/sdm845/apq8016 Acked-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
parent
729fc005c8
commit
73ac545caf
@ -1755,6 +1755,100 @@ static int camss_init_subdevices(struct camss *camss)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* camss_link_entities - Register subdev nodes and create links
|
||||
* @camss: CAMSS device
|
||||
*
|
||||
* Return 0 on success or a negative error code on failure
|
||||
*/
|
||||
static int camss_link_entities(struct camss *camss)
|
||||
{
|
||||
int i, j, k;
|
||||
int ret;
|
||||
|
||||
for (i = 0; i < camss->res->csiphy_num; i++) {
|
||||
for (j = 0; j < camss->res->csid_num; j++) {
|
||||
ret = media_create_pad_link(&camss->csiphy[i].subdev.entity,
|
||||
MSM_CSIPHY_PAD_SRC,
|
||||
&camss->csid[j].subdev.entity,
|
||||
MSM_CSID_PAD_SINK,
|
||||
0);
|
||||
if (ret < 0) {
|
||||
dev_err(camss->dev,
|
||||
"Failed to link %s->%s entities: %d\n",
|
||||
camss->csiphy[i].subdev.entity.name,
|
||||
camss->csid[j].subdev.entity.name,
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (camss->ispif) {
|
||||
for (i = 0; i < camss->res->csid_num; i++) {
|
||||
for (j = 0; j < camss->ispif->line_num; j++) {
|
||||
ret = media_create_pad_link(&camss->csid[i].subdev.entity,
|
||||
MSM_CSID_PAD_SRC,
|
||||
&camss->ispif->line[j].subdev.entity,
|
||||
MSM_ISPIF_PAD_SINK,
|
||||
0);
|
||||
if (ret < 0) {
|
||||
dev_err(camss->dev,
|
||||
"Failed to link %s->%s entities: %d\n",
|
||||
camss->csid[i].subdev.entity.name,
|
||||
camss->ispif->line[j].subdev.entity.name,
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < camss->ispif->line_num; i++)
|
||||
for (k = 0; k < camss->res->vfe_num; k++)
|
||||
for (j = 0; j < camss->vfe[k].res->line_num; j++) {
|
||||
struct v4l2_subdev *ispif = &camss->ispif->line[i].subdev;
|
||||
struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev;
|
||||
|
||||
ret = media_create_pad_link(&ispif->entity,
|
||||
MSM_ISPIF_PAD_SRC,
|
||||
&vfe->entity,
|
||||
MSM_VFE_PAD_SINK,
|
||||
0);
|
||||
if (ret < 0) {
|
||||
dev_err(camss->dev,
|
||||
"Failed to link %s->%s entities: %d\n",
|
||||
ispif->entity.name,
|
||||
vfe->entity.name,
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < camss->res->csid_num; i++)
|
||||
for (k = 0; k < camss->res->vfe_num; k++)
|
||||
for (j = 0; j < camss->vfe[k].res->line_num; j++) {
|
||||
struct v4l2_subdev *csid = &camss->csid[i].subdev;
|
||||
struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev;
|
||||
|
||||
ret = media_create_pad_link(&csid->entity,
|
||||
MSM_CSID_PAD_FIRST_SRC + j,
|
||||
&vfe->entity,
|
||||
MSM_VFE_PAD_SINK,
|
||||
0);
|
||||
if (ret < 0) {
|
||||
dev_err(camss->dev,
|
||||
"Failed to link %s->%s entities: %d\n",
|
||||
csid->entity.name,
|
||||
vfe->entity.name,
|
||||
ret);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* camss_register_entities - Register subdev nodes and create links
|
||||
* @camss: CAMSS device
|
||||
@ -1763,7 +1857,7 @@ static int camss_init_subdevices(struct camss *camss)
|
||||
*/
|
||||
static int camss_register_entities(struct camss *camss)
|
||||
{
|
||||
int i, j, k;
|
||||
int i;
|
||||
int ret;
|
||||
|
||||
for (i = 0; i < camss->res->csiphy_num; i++) {
|
||||
@ -1791,8 +1885,7 @@ static int camss_register_entities(struct camss *camss)
|
||||
ret = msm_ispif_register_entities(camss->ispif,
|
||||
&camss->v4l2_dev);
|
||||
if (ret < 0) {
|
||||
dev_err(camss->dev, "Failed to register ispif entities: %d\n",
|
||||
ret);
|
||||
dev_err(camss->dev, "Failed to register ispif entities: %d\n", ret);
|
||||
goto err_reg_ispif;
|
||||
}
|
||||
|
||||
@ -1807,92 +1900,8 @@ static int camss_register_entities(struct camss *camss)
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < camss->res->csiphy_num; i++) {
|
||||
for (j = 0; j < camss->res->csid_num; j++) {
|
||||
ret = media_create_pad_link(
|
||||
&camss->csiphy[i].subdev.entity,
|
||||
MSM_CSIPHY_PAD_SRC,
|
||||
&camss->csid[j].subdev.entity,
|
||||
MSM_CSID_PAD_SINK,
|
||||
0);
|
||||
if (ret < 0) {
|
||||
dev_err(camss->dev,
|
||||
"Failed to link %s->%s entities: %d\n",
|
||||
camss->csiphy[i].subdev.entity.name,
|
||||
camss->csid[j].subdev.entity.name,
|
||||
ret);
|
||||
goto err_link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (camss->ispif) {
|
||||
for (i = 0; i < camss->res->csid_num; i++) {
|
||||
for (j = 0; j < camss->ispif->line_num; j++) {
|
||||
ret = media_create_pad_link(
|
||||
&camss->csid[i].subdev.entity,
|
||||
MSM_CSID_PAD_SRC,
|
||||
&camss->ispif->line[j].subdev.entity,
|
||||
MSM_ISPIF_PAD_SINK,
|
||||
0);
|
||||
if (ret < 0) {
|
||||
dev_err(camss->dev,
|
||||
"Failed to link %s->%s entities: %d\n",
|
||||
camss->csid[i].subdev.entity.name,
|
||||
camss->ispif->line[j].subdev.entity.name,
|
||||
ret);
|
||||
goto err_link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < camss->ispif->line_num; i++)
|
||||
for (k = 0; k < camss->res->vfe_num; k++)
|
||||
for (j = 0; j < camss->vfe[k].res->line_num; j++) {
|
||||
struct v4l2_subdev *ispif = &camss->ispif->line[i].subdev;
|
||||
struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev;
|
||||
|
||||
ret = media_create_pad_link(&ispif->entity,
|
||||
MSM_ISPIF_PAD_SRC,
|
||||
&vfe->entity,
|
||||
MSM_VFE_PAD_SINK,
|
||||
0);
|
||||
if (ret < 0) {
|
||||
dev_err(camss->dev,
|
||||
"Failed to link %s->%s entities: %d\n",
|
||||
ispif->entity.name,
|
||||
vfe->entity.name,
|
||||
ret);
|
||||
goto err_link;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < camss->res->csid_num; i++)
|
||||
for (k = 0; k < camss->res->vfe_num; k++)
|
||||
for (j = 0; j < camss->vfe[k].res->line_num; j++) {
|
||||
struct v4l2_subdev *csid = &camss->csid[i].subdev;
|
||||
struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev;
|
||||
|
||||
ret = media_create_pad_link(&csid->entity,
|
||||
MSM_CSID_PAD_FIRST_SRC + j,
|
||||
&vfe->entity,
|
||||
MSM_VFE_PAD_SINK,
|
||||
0);
|
||||
if (ret < 0) {
|
||||
dev_err(camss->dev,
|
||||
"Failed to link %s->%s entities: %d\n",
|
||||
csid->entity.name,
|
||||
vfe->entity.name,
|
||||
ret);
|
||||
goto err_link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_link:
|
||||
i = camss->res->vfe_num;
|
||||
err_reg_vfe:
|
||||
for (i--; i >= 0; i--)
|
||||
msm_vfe_unregister_entities(&camss->vfe[i]);
|
||||
@ -2212,6 +2221,10 @@ static int camss_probe(struct platform_device *pdev)
|
||||
if (ret < 0)
|
||||
goto err_v4l2_device_unregister;
|
||||
|
||||
ret = camss->res->link_entities(camss);
|
||||
if (ret < 0)
|
||||
goto err_register_subdevs;
|
||||
|
||||
if (num_subdevs) {
|
||||
camss->notifier.ops = &camss_subdev_notifier_ops;
|
||||
|
||||
@ -2291,6 +2304,7 @@ static const struct camss_resources msm8916_resources = {
|
||||
.csiphy_num = ARRAY_SIZE(csiphy_res_8x16),
|
||||
.csid_num = ARRAY_SIZE(csid_res_8x16),
|
||||
.vfe_num = ARRAY_SIZE(vfe_res_8x16),
|
||||
.link_entities = camss_link_entities
|
||||
};
|
||||
|
||||
static const struct camss_resources msm8996_resources = {
|
||||
@ -2302,6 +2316,7 @@ static const struct camss_resources msm8996_resources = {
|
||||
.csiphy_num = ARRAY_SIZE(csiphy_res_8x96),
|
||||
.csid_num = ARRAY_SIZE(csid_res_8x96),
|
||||
.vfe_num = ARRAY_SIZE(vfe_res_8x96),
|
||||
.link_entities = camss_link_entities
|
||||
};
|
||||
|
||||
static const struct camss_resources sdm660_resources = {
|
||||
@ -2313,6 +2328,7 @@ static const struct camss_resources sdm660_resources = {
|
||||
.csiphy_num = ARRAY_SIZE(csiphy_res_660),
|
||||
.csid_num = ARRAY_SIZE(csid_res_660),
|
||||
.vfe_num = ARRAY_SIZE(vfe_res_660),
|
||||
.link_entities = camss_link_entities
|
||||
};
|
||||
|
||||
static const struct camss_resources sdm845_resources = {
|
||||
@ -2323,6 +2339,7 @@ static const struct camss_resources sdm845_resources = {
|
||||
.csiphy_num = ARRAY_SIZE(csiphy_res_845),
|
||||
.csid_num = ARRAY_SIZE(csid_res_845),
|
||||
.vfe_num = ARRAY_SIZE(vfe_res_845),
|
||||
.link_entities = camss_link_entities
|
||||
};
|
||||
|
||||
static const struct camss_resources sm8250_resources = {
|
||||
@ -2336,6 +2353,7 @@ static const struct camss_resources sm8250_resources = {
|
||||
.csiphy_num = ARRAY_SIZE(csiphy_res_8250),
|
||||
.csid_num = ARRAY_SIZE(csid_res_8250),
|
||||
.vfe_num = ARRAY_SIZE(vfe_res_8250),
|
||||
.link_entities = camss_link_entities
|
||||
};
|
||||
|
||||
static const struct camss_resources sc8280xp_resources = {
|
||||
@ -2350,6 +2368,7 @@ static const struct camss_resources sc8280xp_resources = {
|
||||
.csiphy_num = ARRAY_SIZE(csiphy_res_sc8280xp),
|
||||
.csid_num = ARRAY_SIZE(csid_res_sc8280xp),
|
||||
.vfe_num = ARRAY_SIZE(vfe_res_sc8280xp),
|
||||
.link_entities = camss_link_entities
|
||||
};
|
||||
|
||||
static const struct of_device_id camss_dt_match[] = {
|
||||
|
@ -98,6 +98,7 @@ struct camss_resources {
|
||||
const unsigned int csiphy_num;
|
||||
const unsigned int csid_num;
|
||||
const unsigned int vfe_num;
|
||||
int (*link_entities)(struct camss *camss);
|
||||
};
|
||||
|
||||
struct camss {
|
||||
|
Loading…
Reference in New Issue
Block a user