media: qcom: camss: Fix the X1E80100 lite CSID paths
Subsystems (4)
cover media: qcom: camss: Fix the X1E80100 lite CSID paths
The X1E80100 CAMSS resources, which Glymur reuses for its CSIDs and VFEs (also with Nihal's Glymur-specific resources [1]), have two problems on the lite paths:
- the lite CSIDs are given the full CSID clocks, so their CSI-2 receiver is never clocked and they never see a frame;
- CAMSS assumes CSID n feeds VFE n, but X1E80100 has three full CSIDs and two full VFEs, so CSID_LITE0 powers VFE_LITE1, CSID_LITE1 has no VFE to power and CSID2 powers VFE_LITE0.
Tested on an Asus Zenbook A16 (Glymur), Linux 7.3 with the X1E80100 CSID/VFE tables, streaming 8 frames from the HM1092 IR sensor on CSIPHY0 through each CSID/VFE pair with media-ctl and v4l2-ctl:
before after CSID0 -> VFE0 8 frames 8 frames CSID1 -> VFE1 8 frames 8 frames LITE0 -> LITE0 no frames 8 frames LITE1 -> LITE1 -EINVAL 8 frames CSID2 -> VFE0 no frames -EINVAL
The OV02C10 RGB sensor on CSIPHY4 through LITE1 -> LITE1 also goes from -EINVAL to 8 frames. libcamera still captures from both cameras. I ran the same tests again with Nihal's v3 [1] applied and the board's CSIPHY4 link on port@2, with the same results.
I don't have an X1E80100 machine; testing there would be welcome.
The series applies on its own and in either order with [1]. Patch 2 touches vfe_parent_dev_ops_get() like Allan's "media: qcom: camss: do not fail CSID power up without a matching VFE" [2]. They don't depend on each other; I'm happy to rebase on whichever lands first.
[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/[email protected]
Jesse Casco (2):
media: qcom: camss: x1e80100: Use the lite clocks for the lite CSIDs
media: qcom: camss: Map each CSID to the VFE it feeds
drivers/media/platform/qcom/camss/camss.c | 54 +++++++++++++++++++---- 1 file changed, 45 insertions(+), 9 deletions(-)
base-commit: adcad7f4e6332cff3d6d7165f41584899f598534
Signature · 1 line
2.56.1
PATCH 1/2 media: qcom: camss: x1e80100: Use the lite clocks for the lite CSIDs
The X1E80100 CSID_LITE0 and CSID_LITE1 resources list the full CSID clocks, "csid" and "csid_csiphy_rx", instead of "vfe_lite_csid" and "vfe_lite_cphy_rx", which the binding provides for them. The lite CSIDs then run with their own CSI-2 receiver unclocked: their registers can be read and they raise the reset interrupt, but they never report RX, RDI or buffer-done interrupts, so no frame arrives.
Use the lite clocks, with the vfe_lite_csid rates the IFE_LITE entries already use.
--- drivers/media/platform/qcom/camss/camss.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/platform/qcom/camss/camss.c +4 -4
@@ -4287,13 +4287,13 @@ static const struct camss_subdev_resources csid_res_x1e80100[] = { { .regulators = {}, .clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", - "cpas_fast_ahb", "csid", "csid_csiphy_rx" }, + "cpas_fast_ahb", "vfe_lite_csid", "vfe_lite_cphy_rx" }, .clock_rate = { { 0 }, { 0 }, { 64000000, 80000000 }, { 80000000, 100000000, 200000000, 300000000, 400000000 }, - { 300000000, 400000000, 480000000 }, + { 266666667, 400000000, 480000000 }, { 300000000, 400000000, 480000000 }, }, .reg = { "csid_lite0" }, .interrupt = { "csid_lite0" },
@@ -4308,13 +4308,13 @@ static const struct camss_subdev_resources csid_res_x1e80100[] = { { .regulators = {}, .clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", - "cpas_fast_ahb", "csid", "csid_csiphy_rx" }, + "cpas_fast_ahb", "vfe_lite_csid", "vfe_lite_cphy_rx" }, .clock_rate = { { 0 }, { 0 }, { 64000000, 80000000 }, { 80000000, 100000000, 200000000, 300000000, 400000000 }, - { 300000000, 400000000, 480000000 }, + { 266666667, 400000000, 480000000 }, { 300000000, 400000000, 480000000 }, }, .reg = { "csid_lite1" },
Signature · 1 line
2.56.1
Re: [PATCH 1/2] media: qcom: camss: x1e80100: Use the lite clocks for the lite CSIDs
Quoted 8 lines · Jesse Casco
The X1E80100
CSID_LITE0andCSID_LITE1resources list the full CSID clocks, "csid" and "csid_csiphy_rx", instead of "vfe_lite_csid" and "vfe_lite_cphy_rx", which the binding provides for them. The lite CSIDs then run with their own CSI-2 receiver unclocked: their registers can be read and they raise the reset interrupt, but they never report RX, RDI or buffer-done interrupts, so no frame arrives.
Quoted 5 lines
Use the lite clocks, with the
vfe_lite_csidrates theIFE_LITEentries already use.Fixes 1830cf0f56c3 ("media: qcom: camss: Add x1e80100 specific support")Signed-off-by Jesse Casco <[email protected]>
Quoted 43 lines
--- drivers/media/platform/qcom/camss/camss.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/media/platform/qcom/camss/camss.c +4
-5@@ -4287,13 +4287,13 @@ static const struct camss_subdev_resources csid_res_x1e80100[] = { { .regulators = {}, .clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", - "cpas_fast_ahb", "csid", "csid_csiphy_rx" }, + "cpas_fast_ahb", "vfe_lite_csid", "vfe_lite_cphy_rx" }, .clock_rate = { { 0 }, { 0 }, { 64000000, 80000000 }, { 80000000, 100000000, 200000000, 300000000, 400000000 }, - { 300000000, 400000000, 480000000 }, + { 266666667, 400000000, 480000000 }, { 300000000, 400000000, 480000000 }, }, .reg = { "csid_lite0" }, .interrupt = { "csid_lite0" },@@ -4308,13 +4308,13 @@ static const struct camss_subdev_resources csid_res_x1e80100[] = { { .regulators = {}, .clock = { "gcc_axi_hf", "gcc_axi_sf", "cpas_ahb", - "cpas_fast_ahb", "csid", "csid_csiphy_rx" }, + "cpas_fast_ahb", "vfe_lite_csid", "vfe_lite_cphy_rx" }, .clock_rate = { { 0 }, { 0 }, { 64000000, 80000000 }, { 80000000, 100000000, 200000000, 300000000, 400000000 }, - { 300000000, 400000000, 480000000 }, + { 266666667, 400000000, 480000000 }, { 300000000, 400000000, 480000000 }, }, .reg = { "csid_lite1" }, --2.56.1
PATCH 2/2 media: qcom: camss: Map each CSID to the VFE it feeds
In reply to Jesse CascoCAMSS assumes that CSID n feeds VFE n: csid_set_power() powers the VFE with the CSID's index through parent_dev_ops, camss_buf_done() is passed a CSID index and completes the buffer on the VFE of that index, and camss_reg_update() is passed a VFE index and updates the CSID of that index.
That holds as long as a SoC has the same number of full CSIDs and full VFEs, with the lite blocks after them. X1E80100 has three full CSIDs but only two full VFEs:
CSID: 0, 1, 2, LITE0 (3), LITE1 (4)
VFE: 0, 1, LITE0 (2), LITE1 (3)
so CSID2 powers VFE_LITE0, CSID_LITE0 powers VFE_LITE1, and CSID_LITE1 fails to stream with "Failed to power up pipeline: -22" because there is no VFE 4.
Look the VFE up instead: a full CSID feeds the full VFE with the same index, and the n-th lite CSID feeds the n-th lite VFE. CSID2 has no VFE. This gives the same mapping as before on every other SoC.
--- drivers/media/platform/qcom/camss/camss.c | 46 ++++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-)
drivers/media/platform/qcom/camss/camss.c +41 -5
@@ -4629,11 +4629,39 @@ static int camss_read_version(struct camss *camss)return 0 ; } +/* +* Return the index of the VFE fed by CSID @csid_id, or -EINVAL if it feeds +* none. A full CSID feeds the full VFE with the same index and the n-th lite +* CSID feeds the n-th lite VFE. The two only differ when a SoC has more full +* CSIDs than full VFEs, as X1E80100 does (three full CSIDs, two full VFEs). +*/ +static int camss_csid_to_vfe (struct camss *camss,int csid_id) +{ +const struct camss_resources *res = camss->res; +int i, n =0 ; + +if (!res->csid_res[csid_id].csid.is_lite) { +if (csid_id < res->vfe_num && !res->vfe_res[csid_id].vfe.is_lite) +return csid_id; +return -EINVAL ; + } + +for (i =0 ; i < csid_id; i++) + n += res->csid_res[i].csid.is_lite; + +for (i =0 ; i < res->vfe_num; i++) +if (res->vfe_res[i].vfe.is_lite && n-- ==0 ) +return i; + +return -EINVAL ; +} +static int vfe_parent_dev_ops_get (struct camss *camss,int id) {int ret = -EINVAL ; -if (id < camss->res->vfe_num) { + id =camss_csid_to_vfe (camss, id); +if (id >=0 && id < camss->res->vfe_num) {struct vfe_device *vfe = &camss->vfe[id]; ret =vfe_get (vfe);
@@ -4644,7 +4672,8 @@ static int vfe_parent_dev_ops_get(struct camss *camss, int id)static int vfe_parent_dev_ops_put (struct camss *camss,int id) { -if (id < camss->res->vfe_num) { + id =camss_csid_to_vfe (camss, id); +if (id >=0 && id < camss->res->vfe_num) {struct vfe_device *vfe = &camss->vfe[id];vfe_put (vfe);
@@ -5043,11 +5072,16 @@ static int camss_link_entities(struct camss *camss)void camss_reg_update (struct camss *camss,int hw_id,int port_id,bool is_clear) {struct csid_device *csid; +int i; -if (hw_id < camss->res->csid_num) { - csid = &camss->csid[hw_id]; +/* hw_id is a VFE index; update the CSID that feeds that VFE */ +for (i =0 ; i < camss->res->csid_num; i++) { +if (camss_csid_to_vfe (camss, i) != hw_id) +continue ; + csid = &camss->csid[i]; csid->res->hw_ops->reg_update (csid, port_id, is_clear); +return ; } }
@@ -5055,7 +5089,9 @@ void camss_buf_done(struct camss *camss, int hw_id, int port_id) {struct vfe_device *vfe; -if (hw_id < camss->res->vfe_num) { +/* hw_id is a CSID index; complete the buffer on the VFE it feeds */ + hw_id =camss_csid_to_vfe (camss, hw_id); +if (hw_id >=0 && hw_id < camss->res->vfe_num) { vfe = &camss->vfe[hw_id]; vfe->res->hw_ops->vfe_buf_done (vfe, port_id);
Signature · 1 line
2.56.1
Loic Poulain
reviewerRe: [PATCH 2/2] media: qcom: camss: Map each CSID to the VFE it feeds
Hi Jesse,
Quoted 14 lines · Jesse Casco
CAMSS assumes that CSID n feeds VFE n:
csid_set_power()powers the VFE with the CSID's index throughparent_dev_ops,camss_buf_done()is passed a CSID index and completes the buffer on the VFE of that index, andcamss_reg_update()is passed a VFE index and updates the CSID of that index.That holds as long as a SoC has the same number of full CSIDs and full VFEs, with the lite blocks after them. X1E80100 has three full CSIDs but only two full VFEs:
CSID: 0, 1, 2, LITE0 (3), LITE1 (4)
VFE: 0, 1, LITE0 (2), LITE1 (3)
Quoted 7 lines
so CSID2 powers
VFE_LITE0,CSID_LITE0powersVFE_LITE1, andCSID_LITE1fails to stream with "Failed to power up pipeline: -22" because there is no VFE 4.Look the VFE up instead: a full CSID feeds the full VFE with the same index, and the n-th lite CSID feeds the n-th lite VFE. CSID2 has no VFE. This gives the same mapping as before on every other SoC.
Can you also check there is no possible link in the media graph between LITE and FULL CSID/VFE blocks,
Quoted 95 lines
Fixes 1830cf0f56c3 ("media: qcom: camss: Add x1e80100 specific support")Signed-off-by Jesse Casco <[email protected]>--- drivers/media/platform/qcom/camss/camss.c | 46 ++++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-)drivers/media/platform/qcom/camss/camss.c +41
-6@@ -4629,11 +4629,39 @@ static int camss_read_version(struct camss *camss)return 0 ; } +/* +* Return the index of the VFE fed by CSID @csid_id, or -EINVAL if it feeds +* none. A full CSID feeds the full VFE with the same index and the n-th lite +* CSID feeds the n-th lite VFE. The two only differ when a SoC has more full +* CSIDs than full VFEs, as X1E80100 does (three full CSIDs, two full VFEs). +*/ +static int camss_csid_to_vfe (struct camss *camss,int csid_id) +{ +const struct camss_resources *res = camss->res; +int i, n =0 ; + +if (!res->csid_res[csid_id].csid.is_lite) { +if (csid_id < res->vfe_num && !res->vfe_res[csid_id].vfe.is_lite) +return csid_id; +return -EINVAL ; + } + +for (i =0 ; i < csid_id; i++) + n += res->csid_res[i].csid.is_lite; + +for (i =0 ; i < res->vfe_num; i++) +if (res->vfe_res[i].vfe.is_lite && n-- ==0 ) +return i; + +return -EINVAL ; +} +static int vfe_parent_dev_ops_get (struct camss *camss,int id) {int ret = -EINVAL ; -if (id < camss->res->vfe_num) { + id =camss_csid_to_vfe (camss, id); +if (id >=0 && id < camss->res->vfe_num) {struct vfe_device *vfe = &camss->vfe[id]; ret =vfe_get (vfe);@@ -4644,7 +4672,8 @@ static int vfe_parent_dev_ops_get(struct camss *camss, int id)static int vfe_parent_dev_ops_put (struct camss *camss,int id) { -if (id < camss->res->vfe_num) { + id =camss_csid_to_vfe (camss, id); +if (id >=0 && id < camss->res->vfe_num) {struct vfe_device *vfe = &camss->vfe[id];vfe_put (vfe);@@ -5043,11 +5072,16 @@ static int camss_link_entities(struct camss *camss)void camss_reg_update (struct camss *camss,int hw_id,int port_id,bool is_clear) {struct csid_device *csid; +int i; -if (hw_id < camss->res->csid_num) { - csid = &camss->csid[hw_id]; +/* hw_id is a VFE index; update the CSID that feeds that VFE */ +for (i =0 ; i < camss->res->csid_num; i++) { +if (camss_csid_to_vfe (camss, i) != hw_id) +continue ; + csid = &camss->csid[i]; csid->res->hw_ops->reg_update (csid, port_id, is_clear); +return ; } }@@ -5055,7 +5089,9 @@ void camss_buf_done(struct camss *camss, int hw_id, int port_id) {struct vfe_device *vfe; -if (hw_id < camss->res->vfe_num) { +/* hw_id is a CSID index; complete the buffer on the VFE it feeds */ + hw_id =camss_csid_to_vfe (camss, hw_id); +if (hw_id >=0 && hw_id < camss->res->vfe_num) { vfe = &camss->vfe[hw_id]; vfe->res->hw_ops->vfe_buf_done (vfe, port_id); --2.56.1
Re: [PATCH 2/2] media: qcom: camss: Map each CSID to the VFE it feeds
Hi Loic,
Quoted 21 lines · Loic Poulain
Hi Jesse,
Quoted 18 lines · Jesse Casco
CAMSS assumes that CSID n feeds VFE n:
csid_set_power()powers the VFE with the CSID's index throughparent_dev_ops,camss_buf_done()is passed a CSID index and completes the buffer on the VFE of that index, andcamss_reg_update()is passed a VFE index and updates the CSID of that index.That holds as long as a SoC has the same number of full CSIDs and full VFEs, with the lite blocks after them. X1E80100 has three full CSIDs but only two full VFEs:
CSID: 0, 1, 2, LITE0 (3), LITE1 (4)
VFE: 0, 1, LITE0 (2), LITE1 (3)so CSID2 powers
VFE_LITE0,CSID_LITE0powersVFE_LITE1, andCSID_LITE1fails to stream with "Failed to power up pipeline: -22" because there is no VFE 4.
Quoted 6 lines
Quoted 3 lines
Look the VFE up instead: a full CSID feeds the full VFE with the same index, and the n-th lite CSID feeds the n-th lite VFE. CSID2 has no VFE. This gives the same mapping as before on every other SoC.
Can you also check there is no possible link in the media graph between LITE and FULL CSID/VFE blocks,
For the current state of the driver maybe make sense because "v4l2_pipeline_pm_get" is called in prepare_streaming in camss_video, with previous state of the driver this call was done on video_open.
I think that from sub-device api point of view it is not correct s_power to fail if link is not enabled, but if there is consensus for that logic i think i am also ok...
~Gjorgji
Quoted 97 lines
Quoted 96 lines
Fixes 1830cf0f56c3 ("media: qcom: camss: Add x1e80100 specific support")Signed-off-by Jesse Casco <[email protected]>--- drivers/media/platform/qcom/camss/camss.c | 46 ++++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-)drivers/media/platform/qcom/camss/camss.c +41
-6@@ -4629,11 +4629,39 @@ static int camss_read_version(struct camss *camss)return 0 ; } +/* +* Return the index of the VFE fed by CSID @csid_id, or -EINVAL if it feeds +* none. A full CSID feeds the full VFE with the same index and the n-th lite +* CSID feeds the n-th lite VFE. The two only differ when a SoC has more full +* CSIDs than full VFEs, as X1E80100 does (three full CSIDs, two full VFEs). +*/ +static int camss_csid_to_vfe (struct camss *camss,int csid_id) +{ +const struct camss_resources *res = camss->res; +int i, n =0 ; + +if (!res->csid_res[csid_id].csid.is_lite) { +if (csid_id < res->vfe_num && !res->vfe_res[csid_id].vfe.is_lite) +return csid_id; +return -EINVAL ; + } + +for (i =0 ; i < csid_id; i++) + n += res->csid_res[i].csid.is_lite; + +for (i =0 ; i < res->vfe_num; i++) +if (res->vfe_res[i].vfe.is_lite && n-- ==0 ) +return i; + +return -EINVAL ; +} +static int vfe_parent_dev_ops_get (struct camss *camss,int id) {int ret = -EINVAL ; -if (id < camss->res->vfe_num) { + id =camss_csid_to_vfe (camss, id); +if (id >=0 && id < camss->res->vfe_num) {struct vfe_device *vfe = &camss->vfe[id]; ret =vfe_get (vfe);@@ -4644,7 +4672,8 @@ static int vfe_parent_dev_ops_get(struct camss *camss, int id)static int vfe_parent_dev_ops_put (struct camss *camss,int id) { -if (id < camss->res->vfe_num) { + id =camss_csid_to_vfe (camss, id); +if (id >=0 && id < camss->res->vfe_num) {struct vfe_device *vfe = &camss->vfe[id];vfe_put (vfe);@@ -5043,11 +5072,16 @@ static int camss_link_entities(struct camss *camss)void camss_reg_update (struct camss *camss,int hw_id,int port_id,bool is_clear) {struct csid_device *csid; +int i; -if (hw_id < camss->res->csid_num) { - csid = &camss->csid[hw_id]; +/* hw_id is a VFE index; update the CSID that feeds that VFE */ +for (i =0 ; i < camss->res->csid_num; i++) { +if (camss_csid_to_vfe (camss, i) != hw_id) +continue ; + csid = &camss->csid[i]; csid->res->hw_ops->reg_update (csid, port_id, is_clear); +return ; } }@@ -5055,7 +5089,9 @@ void camss_buf_done(struct camss *camss, int hw_id, int port_id) {struct vfe_device *vfe; -if (hw_id < camss->res->vfe_num) { +/* hw_id is a CSID index; complete the buffer on the VFE it feeds */ + hw_id =camss_csid_to_vfe (camss, hw_id); +if (hw_id >=0 && hw_id < camss->res->vfe_num) { vfe = &camss->vfe[hw_id]; vfe->res->hw_ops->vfe_buf_done (vfe, port_id); --2.56.1
Re: [PATCH 2/2] media: qcom: camss: Map each CSID to the VFE it feeds
Quoted 28 lines · Gjorgji Rosikopulos (Consultant)
Hi Loic,
Quoted 25 lines · Loic Poulain
Hi Jesse,
Quoted 21 lines · Jesse Casco
CAMSS assumes that CSID n feeds VFE n:
csid_set_power()powers the VFE with the CSID's index throughparent_dev_ops,camss_buf_done()is passed a CSID index and completes the buffer on the VFE of that index, andcamss_reg_update()is passed a VFE index and updates the CSID of that index.That holds as long as a SoC has the same number of full CSIDs and full VFEs, with the lite blocks after them. X1E80100 has three full CSIDs but only two full VFEs:
CSID: 0, 1, 2, LITE0 (3), LITE1 (4)
VFE: 0, 1, LITE0 (2), LITE1 (3)so CSID2 powers
VFE_LITE0,CSID_LITE0powersVFE_LITE1, andCSID_LITE1fails to stream with "Failed to power up pipeline: -22" because there is no VFE 4.Look the VFE up instead: a full CSID feeds the full VFE with the same index, and the n-th lite CSID feeds the n-th lite VFE. CSID2 has no VFE. This gives the same mapping as before on every other SoC.
Quoted 8 lines
Quoted 2 lines
Can you also check there is no possible link in the media graph between LITE and FULL CSID/VFE blocks,
For the current state of the driver maybe make sense because "
v4l2_pipeline_pm_get" is called inprepare_streamingincamss_video, with previous state of the driver this call was done onvideo_open.
I think that from sub-device api point of view it is not corrects_powerto fail if link is not enabled, but if there is consensus for that logic i think i am also ok...
Sorry for the confusion actually checking if there is a link present (regardless of the state) i think is ok.
Quoted 101 lines
~Gjorgji
Quoted 97 lines
Quoted 96 lines
Fixes 1830cf0f56c3 ("media: qcom: camss: Add x1e80100 specific support")Signed-off-by Jesse Casco <[email protected]>--- drivers/media/platform/qcom/camss/camss.c | 46 ++++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-)drivers/media/platform/qcom/camss/camss.c +41
-6@@ -4629,11 +4629,39 @@ static int camss_read_version(struct camss *camss)return 0 ; } +/* +* Return the index of the VFE fed by CSID @csid_id, or -EINVAL if it feeds +* none. A full CSID feeds the full VFE with the same index and the n-th lite +* CSID feeds the n-th lite VFE. The two only differ when a SoC has more full +* CSIDs than full VFEs, as X1E80100 does (three full CSIDs, two full VFEs). +*/ +static int camss_csid_to_vfe (struct camss *camss,int csid_id) +{ +const struct camss_resources *res = camss->res; +int i, n =0 ; + +if (!res->csid_res[csid_id].csid.is_lite) { +if (csid_id < res->vfe_num && !res->vfe_res[csid_id].vfe.is_lite) +return csid_id; +return -EINVAL ; + } + +for (i =0 ; i < csid_id; i++) + n += res->csid_res[i].csid.is_lite; + +for (i =0 ; i < res->vfe_num; i++) +if (res->vfe_res[i].vfe.is_lite && n-- ==0 ) +return i; + +return -EINVAL ; +} +static int vfe_parent_dev_ops_get (struct camss *camss,int id) {int ret = -EINVAL ; -if (id < camss->res->vfe_num) { + id =camss_csid_to_vfe (camss, id); +if (id >=0 && id < camss->res->vfe_num) {struct vfe_device *vfe = &camss->vfe[id]; ret =vfe_get (vfe);@@ -4644,7 +4672,8 @@ static int vfe_parent_dev_ops_get(struct camss *camss, int id)static int vfe_parent_dev_ops_put (struct camss *camss,int id) { -if (id < camss->res->vfe_num) { + id =camss_csid_to_vfe (camss, id); +if (id >=0 && id < camss->res->vfe_num) {struct vfe_device *vfe = &camss->vfe[id];vfe_put (vfe);@@ -5043,11 +5072,16 @@ static int camss_link_entities(struct camss *camss)void camss_reg_update (struct camss *camss,int hw_id,int port_id,bool is_clear) {struct csid_device *csid; +int i; -if (hw_id < camss->res->csid_num) { - csid = &camss->csid[hw_id]; +/* hw_id is a VFE index; update the CSID that feeds that VFE */ +for (i =0 ; i < camss->res->csid_num; i++) { +if (camss_csid_to_vfe (camss, i) != hw_id) +continue ; + csid = &camss->csid[i]; csid->res->hw_ops->reg_update (csid, port_id, is_clear); +return ; } }@@ -5055,7 +5089,9 @@ void camss_buf_done(struct camss *camss, int hw_id, int port_id) {struct vfe_device *vfe; -if (hw_id < camss->res->vfe_num) { +/* hw_id is a CSID index; complete the buffer on the VFE it feeds */ + hw_id =camss_csid_to_vfe (camss, hw_id); +if (hw_id >=0 && hw_id < camss->res->vfe_num) { vfe = &camss->vfe[hw_id]; vfe->res->hw_ops->vfe_buf_done (vfe, port_id); --2.56.1
Re: [PATCH 2/2] media: qcom: camss: Map each CSID to the VFE it feeds
In reply to Jesse CascoHi Jesse,
Quoted 73 lines · Jesse Casco
CAMSS assumes that CSID n feeds VFE n:
csid_set_power()powers the VFE with the CSID's index throughparent_dev_ops,camss_buf_done()is passed a CSID index and completes the buffer on the VFE of that index, andcamss_reg_update()is passed a VFE index and updates the CSID of that index.That holds as long as a SoC has the same number of full CSIDs and full VFEs, with the lite blocks after them. X1E80100 has three full CSIDs but only two full VFEs:
CSID: 0, 1, 2, LITE0 (3), LITE1 (4)
VFE: 0, 1, LITE0 (2), LITE1 (3)so CSID2 powers
VFE_LITE0,CSID_LITE0powersVFE_LITE1, andCSID_LITE1fails to stream with "Failed to power up pipeline: -22" because there is no VFE 4.Look the VFE up instead: a full CSID feeds the full VFE with the same index, and the n-th lite CSID feeds the n-th lite VFE. CSID2 has no VFE. This gives the same mapping as before on every other SoC.
Fixes 1830cf0f56c3 ("media: qcom: camss: Add x1e80100 specific support")Signed-off-by Jesse Casco <[email protected]>--- drivers/media/platform/qcom/camss/camss.c | 46 ++++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-)drivers/media/platform/qcom/camss/camss.c +29
-1@@ -4629,11 +4629,39 @@ static int camss_read_version(struct camss *camss)return 0 ; } +/* +* Return the index of the VFE fed by CSID @csid_id, or -EINVAL if it feeds +* none. A full CSID feeds the full VFE with the same index and the n-th lite +* CSID feeds the n-th lite VFE. The two only differ when a SoC has more full +* CSIDs than full VFEs, as X1E80100 does (three full CSIDs, two full VFEs). +*/ +static int camss_csid_to_vfe (struct camss *camss,int csid_id) +{ +const struct camss_resources *res = camss->res; +int i, n =0 ; + +if (!res->csid_res[csid_id].csid.is_lite) { +if (csid_id < res->vfe_num && !res->vfe_res[csid_id].vfe.is_lite) +return csid_id; +return -EINVAL ; + } + +for (i =0 ; i < csid_id; i++) + n += res->csid_res[i].csid.is_lite; + +for (i =0 ; i < res->vfe_num; i++) +if (res->vfe_res[i].vfe.is_lite && n-- ==0 ) +return i; + +return -EINVAL ; +} +static int vfe_parent_dev_ops_get (struct camss *camss,int id) {int ret = -EINVAL ; -if (id < camss->res->vfe_num) { + id =camss_csid_to_vfe (camss, id); +if (id >=0 && id < camss->res->vfe_num) {struct vfe_device *vfe = &camss->vfe[id]; ret =vfe_get (vfe);
drivers/media/platform/qcom/camss/camss.c static int vfe_parent_dev_ops_get(struct camss *camss, int id) · line 4679
Quoted 9 lines
drivers/media/platform/qcom/camss/camss.c +2
-1@@ -4644,7 +4672,8 @@ static int vfe_parent_dev_ops_get(struct camss *camss, int id)static int vfe_parent_dev_ops_put (struct camss *camss,int id) { -if (id < camss->res->vfe_num) { + id =camss_csid_to_vfe (camss, id); +if (id >=0 && id < camss->res->vfe_num) {struct vfe_device *vfe = &camss->vfe[id];vfe_put (vfe);
Those parent device callbacks were actually submitted by me to remove circular dependency between csid and camss. However i see that camss_buf_done is also introduced which make the api kind of mixed.
I will propose to not go thru the camss and those helpers,
but during the creation of the csid the vfe instance to be provided as parent device. Then the csid to call directly vfe avoiding all those helpers which may increase in the future. Maybe csid resources should contain the parent device index as well.
~Gjorgji
Quoted 30 lines
drivers/media/platform/qcom/camss/camss.c +10
-3@@ -5043,11 +5072,16 @@ static int camss_link_entities(struct camss *camss)void camss_reg_update (struct camss *camss,int hw_id,int port_id,bool is_clear) {struct csid_device *csid; +int i; -if (hw_id < camss->res->csid_num) { - csid = &camss->csid[hw_id]; +/* hw_id is a VFE index; update the CSID that feeds that VFE */ +for (i =0 ; i < camss->res->csid_num; i++) { +if (camss_csid_to_vfe (camss, i) != hw_id) +continue ; + csid = &camss->csid[i]; csid->res->hw_ops->reg_update (csid, port_id, is_clear); +return ; } }@@ -5055,7 +5089,9 @@ void camss_buf_done(struct camss *camss, int hw_id, int port_id) {struct vfe_device *vfe; -if (hw_id < camss->res->vfe_num) { +/* hw_id is a CSID index; complete the buffer on the VFE it feeds */ + hw_id =camss_csid_to_vfe (camss, hw_id); +if (hw_id >=0 && hw_id < camss->res->vfe_num) { vfe = &camss->vfe[hw_id]; vfe->res->hw_ops->vfe_buf_done (vfe, port_id);
Re: [PATCH 2/2] media: qcom: camss: Map each CSID to the VFE it feeds
Quoted 1 line · Gjorgji Rosikopulos (Consultant)
Maybe csid resources should contain the parent device index as well.
That doesn't work on the ISPIF based SoCs: MSM8916/MSM8226 have two CSIDs and one VFE, and the ISPIF routes either CSID to VFE0. The parent has to come from the media link. CSID1 currently fails with -EINVAL in vfe_parent_dev_ops_get() (no VFE1); minimal fix:
https://lore.kernel.org/r/[email protected]
I'll drop it if the parent is resolved from the link as in Jesse's 2/2.
Allan
Hi Jesse,
Quoted 14 lines · Jesse Casco
The X1E80100 CAMSS resources, which Glymur reuses for its CSIDs and VFEs (also with Nihal's Glymur-specific resources [1]), have two problems on the lite paths:
- the lite CSIDs are given the full CSID clocks, so their CSI-2 receiver is never clocked and they never see a frame;
- CAMSS assumes CSID n feeds VFE n, but X1E80100 has three full CSIDs and two full VFEs, soCSID_LITE0powersVFE_LITE1,CSID_LITE1has no VFE to power and CSID2 powersVFE_LITE0.Tested on an Asus Zenbook A16 (Glymur), Linux 7.3 with the X1E80100 CSID/VFE tables, streaming 8 frames from the HM1092 IR sensor on CSIPHY0 through each CSID/VFE pair with media-ctl and v4l2-ctl:
Quoted 6 lines
before after CSID0 -> VFE0 8 frames 8 frames CSID1 -> VFE1 8 frames 8 frames LITE0 -> LITE0 no frames 8 frames LITE1 -> LITE1 -EINVAL 8 frames CSID2 -> VFE0 no frames -EINVAL
Just to note that my opinion is that CSID2 shall be removed from the resources since can not be used as of today. But others may share different opinion.
~Gjorgji
Quoted 25 lines
The OV02C10 RGB sensor on CSIPHY4 through LITE1 -> LITE1 also goes from
-EINVALto 8 frames. libcamera still captures from both cameras. I ran the same tests again with Nihal's v3 [1] applied and the board's CSIPHY4 link on port@2, with the same results.I don't have an X1E80100 machine; testing there would be welcome.
The series applies on its own and in either order with [1]. Patch 2 touches
vfe_parent_dev_ops_get()like Allan's "media: qcom: camss: do not fail CSID power up without a matching VFE" [2]. They don't depend on each other; I'm happy to rebase on whichever lands first.[1] https://lore.kernel.org/r/[email protected]
[2] https://lore.kernel.org/r/[email protected]Jesse Casco (2):
media: qcom: camss: x1e80100: Use the lite clocks for the lite CSIDs
media: qcom: camss: Map each CSID to the VFE it feedsdrivers/media/platform/qcom/camss/camss.c | 54 +++++++++++++++++++---- 1 file changed, 45 insertions(+), 9 deletions(-)base-commit:
adcad7f4e6332cff3d6d7165f41584899f598534
Quoted 3 lines · Gjorgji Rosikopulos (Consultant)
Just to note that my opinion is that CSID2 shall be removed from the resources since can not be used as of today. But others may share different opinion.
Hi Gjorgji,
Agreed, I'll drop CSID2 in v2. That also makes CSID n -> VFE n hold again on X1E80100.
Jesse