Omap3isp CCP2 support
v2 cover Omap3isp CCP2 support
Hi folks,
Here's a respin of the omap3isp ccp2 support patches.
since v1:
- Root out patches already merged or not needed (omapisp: Ignore endpoints with invalid configuration).
- Rework the patch skipping CSI-2 receiver configuration for CCP2 ("omap3isp: Skip CSI-2 receiver initialisation in CCP2 configuration"). Instead of trying to figure out which receiver (CSI-2 or CCP2) is used, store the information to the isp_csiphy struct instead.
- Added a patch to correctly release a CSI-2 phy --- the PHY configuration coming from DT was previously ignored.
Pavel Machek (2):
omap3isp: Parse CSI1 configuration from the device tree
omap3isp: Correctly set IO_OUT_SEL and VP_CLK_POL for CCP2 mode
Sakari Ailus (3):
omap3isp: Always initialise isp and mutex for csiphy1
omap3isp: csiphy: Don't assume the CSI receiver is a CSI2 module
omap3isp: Correctly configure routing in PHY release
drivers/media/platform/omap3isp/isp.c | 105 +++++++++++++++++++++------- drivers/media/platform/omap3isp/ispccp2.c | 9 ++- drivers/media/platform/omap3isp/ispcsi2.c | 4 +- drivers/media/platform/omap3isp/ispcsiphy.c | 59 ++++++++-------- drivers/media/platform/omap3isp/ispcsiphy.h | 6 +- drivers/media/platform/omap3isp/ispreg.h | 4 ++ drivers/media/platform/omap3isp/omap3isp.h | 1 + 7 files changed, 126 insertions(+), 62 deletions(-)
Signature · 1 line
2.11.0
PATCH v2 1/5 omap3isp: Parse CSI1 configuration from the device tree
From: Pavel Machek <[email protected]>
Add support for parsing CSI1 configuration.
--- drivers/media/platform/omap3isp/isp.c | 105 +++++++++++++++++++++-------- drivers/media/platform/omap3isp/omap3isp.h | 1 + 2 files changed, 79 insertions(+), 27 deletions(-)
drivers/media/platform/omap3isp/isp.c +78 -27
@@ -2018,6 +2018,7 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwnode,struct v4l2_fwnode_endpoint vep;unsigned int i;int ret; +bool csi1 = false; ret =v4l2_fwnode_endpoint_parse (fwnode, &vep);if (ret)
@@ -2047,41 +2048,91 @@ static int isp_fwnode_parse(struct device *dev, struct fwnode_handle *fwnode,case ISP_OF_PHY_CSIPHY1 :case ISP_OF_PHY_CSIPHY2 : -/* FIXME: always assume CSI-2 for now. */ +switch (vep.bus_type) { +case V4L2_MBUS_CCP2 : +case V4L2_MBUS_CSI1 : +dev_dbg (dev,"CSI-1/CCP-2 configuration\n" ); + csi1 = true; +break ; +case V4L2_MBUS_CSI2 : +dev_dbg (dev,"CSI-2 configuration\n" ); + csi1 = false; +break ; +default : +dev_err (dev,"unsupported bus type %u\n" , + vep.bus_type); +return -EINVAL ; + } +switch (vep.base.port) {case ISP_OF_PHY_CSIPHY1 : - buscfg->interface =ISP_INTERFACE_CSI2C_PHY1 ; +if (csi1) + buscfg->interface =ISP_INTERFACE_CCP2B_PHY1 ; +else + buscfg->interface =ISP_INTERFACE_CSI2C_PHY1 ;break ;case ISP_OF_PHY_CSIPHY2 : - buscfg->interface =ISP_INTERFACE_CSI2A_PHY2 ; +if (csi1) + buscfg->interface =ISP_INTERFACE_CCP2B_PHY2 ; +else + buscfg->interface =ISP_INTERFACE_CSI2A_PHY2 ;break ; } - buscfg->bus.csi2.lanecfg.clk.pos = vep.bus.mipi_csi2.clock_lane; - buscfg->bus.csi2.lanecfg.clk.pol = - vep.bus.mipi_csi2.lane_polarities[0 ]; -dev_dbg (dev,"clock lane polarity %u, pos %u\n" , - buscfg->bus.csi2.lanecfg.clk.pol, - buscfg->bus.csi2.lanecfg.clk.pos); - - buscfg->bus.csi2.num_data_lanes = - vep.bus.mipi_csi2.num_data_lanes; - -for (i =0 ; i < buscfg->bus.csi2.num_data_lanes; i++) { - buscfg->bus.csi2.lanecfg.data[i].pos = - vep.bus.mipi_csi2.data_lanes[i]; - buscfg->bus.csi2.lanecfg.data[i].pol = - vep.bus.mipi_csi2.lane_polarities[i +1 ]; +if (csi1) { + buscfg->bus.ccp2.lanecfg.clk.pos = + vep.bus.mipi_csi1.clock_lane; + buscfg->bus.ccp2.lanecfg.clk.pol = + vep.bus.mipi_csi1.lane_polarity[0 ]; +dev_dbg (dev,"clock lane polarity %u, pos %u\n" , + buscfg->bus.ccp2.lanecfg.clk.pol, + buscfg->bus.ccp2.lanecfg.clk.pos); + + buscfg->bus.ccp2.lanecfg.data[0 ].pos = + vep.bus.mipi_csi1.data_lane; + buscfg->bus.ccp2.lanecfg.data[0 ].pol = + vep.bus.mipi_csi1.lane_polarity[1 ]; +dev_dbg (dev,"data lane %u polarity %u, pos %u\n" , i, - buscfg->bus.csi2.lanecfg.data[i].pol, - buscfg->bus.csi2.lanecfg.data[i].pos); + buscfg->bus.ccp2.lanecfg.data[0 ].pol, + buscfg->bus.ccp2.lanecfg.data[0 ].pos); + + buscfg->bus.ccp2.strobe_clk_pol = + vep.bus.mipi_csi1.clock_inv; + buscfg->bus.ccp2.phy_layer = vep.bus.mipi_csi1.strobe; + buscfg->bus.ccp2.ccp2_mode = + vep.bus_type ==V4L2_MBUS_CCP2 ; + buscfg->bus.ccp2.vp_clk_pol =1 ; + + buscfg->bus.ccp2.crc =1 ; + }else { + buscfg->bus.csi2.lanecfg.clk.pos = + vep.bus.mipi_csi2.clock_lane; + buscfg->bus.csi2.lanecfg.clk.pol = + vep.bus.mipi_csi2.lane_polarities[0 ]; +dev_dbg (dev,"clock lane polarity %u, pos %u\n" , + buscfg->bus.csi2.lanecfg.clk.pol, + buscfg->bus.csi2.lanecfg.clk.pos); + + buscfg->bus.csi2.num_data_lanes = + vep.bus.mipi_csi2.num_data_lanes; + +for (i =0 ; i < buscfg->bus.csi2.num_data_lanes; i++) { + buscfg->bus.csi2.lanecfg.data[i].pos = + vep.bus.mipi_csi2.data_lanes[i]; + buscfg->bus.csi2.lanecfg.data[i].pol = + vep.bus.mipi_csi2.lane_polarities[i +1 ]; +dev_dbg (dev, +"data lane %u polarity %u, pos %u\n" , i, + buscfg->bus.csi2.lanecfg.data[i].pol, + buscfg->bus.csi2.lanecfg.data[i].pos); + } +/* +* FIXME: now we assume the CRC is always there. +* Implement a way to obtain this information from the +* sensor. Frame descriptors, perhaps? +*/ + buscfg->bus.csi2.crc =1 ; } - -/* -* FIXME: now we assume the CRC is always there. -* Implement a way to obtain this information from the -* sensor. Frame descriptors, perhaps? -*/ - buscfg->bus.csi2.crc =1 ;break ;default :
drivers/media/platform/omap3isp/omap3isp.h +1 -0
@@ -110,6 +110,7 @@ struct isp_ccp2_cfg { unsigned int ccp2_mode:1; unsigned int phy_layer:1; unsigned int vpclk_div:2; + unsigned int vp_clk_pol:1;struct isp_csiphy_lanes_cfg lanecfg; };
Signature · 1 line
2.11.0
PATCH v2 2/5 omap3isp: Correctly set IO_OUT_SEL and VP_CLK_POL for CCP2 mode
In reply to Sakari AilusFrom: Pavel Machek <[email protected]>
ISP CSI1 module needs all the bits correctly set to work.
--- drivers/media/platform/omap3isp/ispccp2.c | 7 +++++-- drivers/media/platform/omap3isp/ispreg.h | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/media/platform/omap3isp/ispccp2.c +5 -2
@@ -213,14 +213,17 @@ static int ccp2_phyif_config(struct isp_ccp2_device *ccp2,struct isp_device *isp =to_isp_device (ccp2);u32 val; -/* CCP2B mode */ val =isp_reg_readl (isp,OMAP3_ISP_IOMEM_CCP2 ,ISPCCP2_CTRL ) | -ISPCCP2_CTRL_IO_OUT_SEL |ISPCCP2_CTRL_MODE ; +ISPCCP2_CTRL_MODE ;/* Data/strobe physical layer */ BIT_SET (val,ISPCCP2_CTRL_PHY_SEL_SHIFT ,ISPCCP2_CTRL_PHY_SEL_MASK , buscfg->phy_layer); +BIT_SET (val,ISPCCP2_CTRL_IO_OUT_SEL_SHIFT , +ISPCCP2_CTRL_IO_OUT_SEL_MASK , buscfg->ccp2_mode);BIT_SET (val,ISPCCP2_CTRL_INV_SHIFT ,ISPCCP2_CTRL_INV_MASK , buscfg->strobe_clk_pol); +BIT_SET (val,ISPCCP2_CTRL_VP_CLK_POL_SHIFT , +ISPCCP2_CTRL_VP_CLK_POL_MASK , buscfg->vp_clk_pol);isp_reg_writel (isp, val,OMAP3_ISP_IOMEM_CCP2 ,ISPCCP2_CTRL ); val =isp_reg_readl (isp,OMAP3_ISP_IOMEM_CCP2 ,ISPCCP2_CTRL );
drivers/media/platform/omap3isp/ispreg.h +4 -0
@@ -87,6 +87,8 @@#define ISPCCP2_CTRL_PHY_SEL_MASK 0x1#define ISPCCP2_CTRL_PHY_SEL_SHIFT 1#define ISPCCP2_CTRL_IO_OUT_SEL (1 << 2) +#define ISPCCP2_CTRL_IO_OUT_SEL_MASK 0x1 +#define ISPCCP2_CTRL_IO_OUT_SEL_SHIFT 2#define ISPCCP2_CTRL_MODE (1 << 4)#define ISPCCP2_CTRL_VP_CLK_FORCE_ON (1 << 9)#define ISPCCP2_CTRL_INV (1 << 10)
@@ -94,6 +96,8 @@#define ISPCCP2_CTRL_INV_SHIFT 10#define ISPCCP2_CTRL_VP_ONLY_EN (1 << 11)#define ISPCCP2_CTRL_VP_CLK_POL (1 << 12) +#define ISPCCP2_CTRL_VP_CLK_POL_MASK 0x1 +#define ISPCCP2_CTRL_VP_CLK_POL_SHIFT 12#define ISPCCP2_CTRL_VPCLK_DIV_SHIFT 15#define ISPCCP2_CTRL_VPCLK_DIV_MASK 0x1ffff/* [31:15] */ #define ISPCCP2_CTRL_VP_OUT_CTRL_SHIFT 8/* 3430 bits */
Signature · 1 line
2.11.0
PATCH v2 3/5 omap3isp: Always initialise isp and mutex for csiphy1
In reply to Sakari AilusThe PHY is still relevant for CCP2.
--- drivers/media/platform/omap3isp/ispcsiphy.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/media/platform/omap3isp/ispcsiphy.c +3 -2
@@ -345,13 +345,14 @@ int omap3isp_csiphy_init(struct isp_device *isp) phy2->phy_regs =OMAP3_ISP_IOMEM_CSIPHY2 ;mutex_init (&phy2->mutex); + phy1->isp = isp; +mutex_init (&phy1->mutex); +if (isp->revision ==ISP_REVISION_15_0 ) { - phy1->isp = isp; phy1->csi2 = &isp->isp_csi2c; phy1->num_data_lanes =ISP_CSIPHY1_NUM_DATA_LANES ; phy1->cfg_regs =OMAP3_ISP_IOMEM_CSI2C_REGS1 ; phy1->phy_regs =OMAP3_ISP_IOMEM_CSIPHY1 ; -mutex_init (&phy1->mutex); }return 0 ;
Signature · 1 line
2.11.0
PATCH v2 4/5 omap3isp: csiphy: Don't assume the CSI receiver is a CSI2 module
In reply to Sakari AilusThe CSI PHY is associated with a CSI receiver. The code assumes this receiver is a CSI2 module and relies on the CSI2 module object heavily to access the ISP or pipeline objects. However, the receiver could also be a CSI1/CCP2 module.
Pass a new CSI receiver entity pointer to the CSI PHY acquire function, and replace all hardcoded usage of the CSI2 module with that CSI receiver entity.
--- drivers/media/platform/omap3isp/ispccp2.c | 2 +- drivers/media/platform/omap3isp/ispcsi2.c | 4 +-- drivers/media/platform/omap3isp/ispcsiphy.c | 45 +++++++++++++---------------- drivers/media/platform/omap3isp/ispcsiphy.h | 6 ++-- 4 files changed, 27 insertions(+), 30 deletions(-)
drivers/media/platform/omap3isp/ispccp2.c +1 -1
@@ -841,7 +841,7 @@ static int ccp2_s_stream(struct v4l2_subdev *sd, int enable)switch (enable) {case ISP_PIPELINE_STREAM_CONTINUOUS :if (ccp2->phy) { - ret =omap3isp_csiphy_acquire (ccp2->phy); + ret =omap3isp_csiphy_acquire (ccp2->phy, &sd->entity);if (ret <0 )return ret; }
drivers/media/platform/omap3isp/ispcsi2.c +2 -2
@@ -490,7 +490,7 @@ int omap3isp_csi2_reset(struct isp_csi2_device *csi2)if (!csi2->available)return -ENODEV ; -if (csi2->phy->phy_in_use) +if (csi2->phy->entity)return -EBUSY ; isp_reg_set(isp, csi2->regs1, ISPCSI2_SYSCONFIG,
@@ -1053,7 +1053,7 @@ static int csi2_set_stream(struct v4l2_subdev *sd, int enable)switch (enable) {case ISP_PIPELINE_STREAM_CONTINUOUS : -if (omap3isp_csiphy_acquire (csi2->phy) <0 ) +if (omap3isp_csiphy_acquire (csi2->phy, &sd->entity) <0 )return -ENODEV ;if (csi2->output &CSI2_OUTPUT_MEMORY )omap3isp_sbl_enable (isp,OMAP3_ISP_SBL_CSI2A_WRITE );
drivers/media/platform/omap3isp/ispcsiphy.c +20 -25
113 lines not on this page · raw message
drivers/media/platform/omap3isp/ispcsiphy.h +4 -2
@@ -25,9 +25,10 @@ struct regulator;struct isp_csiphy {struct isp_device *isp;struct mutex mutex;/* serialize csiphy configuration */ -u8 phy_in_use;struct isp_csi2_device *csi2;struct regulator *vdd; +/* the entity that acquired the phy */ +struct media_entity *entity;/* mem resources - enums as defined in enum isp_mem_resources */ unsigned int cfg_regs;
@@ -36,7 +37,8 @@ struct isp_csiphy {u8 num_data_lanes;/* number of CSI2 Data Lanes supported */ }; -int omap3isp_csiphy_acquire (struct isp_csiphy *phy); +int omap3isp_csiphy_acquire (struct isp_csiphy *phy, +struct media_entity *entity);void omap3isp_csiphy_release (struct isp_csiphy *phy);int omap3isp_csiphy_init (struct isp_device *isp);void omap3isp_csiphy_cleanup (struct isp_device *isp);
Signature · 1 line
2.11.0
Re: [PATCH v2 4/5] omap3isp: csiphy: Don't assume the CSI receiver is a CSI2 module
Hi Sakari,
Thank you for the patch.
Quoted 5 lines · On Wednesday 16 Aug 2017 15:51:49 Sakari Ailus wrote:
The CSI PHY is associated with a CSI receiver. The code assumes this receiver is a CSI2 module and relies on the CSI2 module object heavily to access the ISP or pipeline objects. However, the receiver could also be a CSI1/CCP2 module.
Quoted 8 lines
Pass a new CSI receiver entity pointer to the CSI PHY acquire function, and replace all hardcoded usage of the CSI2 module with that CSI receiver entity.
Signed-off-by Sakari Ailus <[email protected]>Beagleboard-xM + MPT9P031
Acked-by Pavel Machek <[email protected]>
Quoted 51 lines
--- drivers/media/platform/omap3isp/ispccp2.c | 2 +- drivers/media/platform/omap3isp/ispcsi2.c | 4 +-- drivers/media/platform/omap3isp/ispcsiphy.c | 45 +++++++++++-------------- drivers/media/platform/omap3isp/ispcsiphy.h | 6 ++-- 4 files changed, 27 insertions(+), 30 deletions(-)(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispccp2.cindex47210b102bcb..3db8df09cd9a100644drivers/media/platform/omap3isp/ispccp2.c +1
-1@@ -841,7 +841,7 @@ static int ccp2_s_stream(struct v4l2_subdev *sd, int enable) switch (enable) {case ISP_PIPELINE_STREAM_CONTINUOUS :if (ccp2->phy) { - ret =omap3isp_csiphy_acquire (ccp2->phy); + ret =omap3isp_csiphy_acquire (ccp2->phy, &sd->entity);if (ret <0 )return ret; }(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispcsi2.cindex7dae2fe0d42d..3ec37fed710b100644drivers/media/platform/omap3isp/ispcsi2.c +2
-2@@ -490,7 +490,7 @@ int omap3isp_csi2_reset(struct isp_csi2_device *csi2)if (!csi2->available)return -ENODEV ; -if (csi2->phy->phy_in_use) +if (csi2->phy->entity)return -EBUSY ; isp_reg_set(isp, csi2->regs1, ISPCSI2_SYSCONFIG,@@ -1053,7 +1053,7 @@ static int csi2_set_stream(struct v4l2_subdev *sd, int enable)switch (enable) {case ISP_PIPELINE_STREAM_CONTINUOUS : -if (omap3isp_csiphy_acquire (csi2->phy) <0 ) +if (omap3isp_csiphy_acquire (csi2->phy, &sd->entity) <0 )return -ENODEV ;if (csi2->output &CSI2_OUTPUT_MEMORY )drivers/media/platform/omap3isp/ispcsi2.c +0
-0omap3isp_sbl_enable (isp,OMAP3_ISP_SBL_CSI2A_WRITE );(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispcsiphy.cindex2028bb519108..ed1eb9907ae0100644
drivers/media/platform/omap3isp/ispcsiphy.c static int csiphy_set_power(struct isp_csiphy *phy, · line 170
Quoted 10 lines
drivers/media/platform/omap3isp/ispcsiphy.c +3
-3@@ -164,22 +164,17 @@ static int csiphy_set_power(struct isp_csiphy *phy, u32 power)static int omap3isp_csiphy_config (struct isp_csiphy *phy) { -struct isp_csi2_device *csi2 = phy->csi2; -struct isp_pipeline *pipe =to_isp_pipeline (&csi2->subdev.entity); -struct isp_bus_cfg *buscfg = pipe->external->host_priv; +struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); +struct isp_async_subdev *isd = + container_of(pipe->external->asd, struct isp_async_subdev,
asd);
Quoted 141 lines
drivers/media/platform/omap3isp/ispcsiphy.c +2
-7+struct isp_bus_cfg *buscfg = pipe->external->host_priv ? + pipe->external->host_priv : &isd->bus;struct isp_csiphy_lanes_cfg *lanes;int csi2_ddrclk_khz;unsigned int num_data_lanes, used_lanes =0 ;unsigned int i;u32 reg; -if (!buscfg) { -struct isp_async_subdev *isd = -container_of (pipe->external->asd, - struct isp_async_subdev, asd); - buscfg = &isd->bus; - } - if (buscfg->interface == ISP_INTERFACE_CCP2B_PHY1drivers/media/platform/omap3isp/ispcsiphy.c +15
-15|| buscfg->interface == ISP_INTERFACE_CCP2B_PHY2) { lanes = &buscfg->bus.ccp2.lanecfg;@@ -222,7 +217,7 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy) csi2_ddrclk_khz = pipe->external_rate / 1000 / (2 *hweight32 (used_lanes)) * pipe->external_width; - reg =isp_reg_readl (csi2->isp, phy->phy_regs,ISPCSIPHY_REG0 ); + reg =isp_reg_readl (phy->isp, phy->phy_regs,ISPCSIPHY_REG0 ); reg &= ~(ISPCSIPHY_REG0_THS_TERM_MASK |ISPCSIPHY_REG0_THS_SETTLE_MASK );@@ -233,9 +228,9 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy) reg |= (DIV_ROUND_UP(90 * csi2_ddrclk_khz, 1000000) + 3) <<ISPCSIPHY_REG0_THS_SETTLE_SHIFT ; -isp_reg_writel (csi2->isp, reg, phy->phy_regs,ISPCSIPHY_REG0 ); +isp_reg_writel (phy->isp, reg, phy->phy_regs,ISPCSIPHY_REG0 ); - reg =isp_reg_readl (csi2->isp, phy->phy_regs,ISPCSIPHY_REG1 ); + reg =isp_reg_readl (phy->isp, phy->phy_regs,ISPCSIPHY_REG1 ); reg &= ~(ISPCSIPHY_REG1_TCLK_TERM_MASK | ISPCSIPHY_REG1_TCLK_MISS_MASK |@@ -244,10 +239,10 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy) reg |= TCLK_MISS << ISPCSIPHY_REG1_TCLK_MISS_SHIFT; reg |=TCLK_SETTLE <<ISPCSIPHY_REG1_TCLK_SETTLE_SHIFT ; -isp_reg_writel (csi2->isp, reg, phy->phy_regs,ISPCSIPHY_REG1 ); +isp_reg_writel (phy->isp, reg, phy->phy_regs,ISPCSIPHY_REG1 );/* DPHY lane configuration */ - reg =isp_reg_readl (csi2->isp, phy->cfg_regs,ISPCSI2_PHY_CFG ); + reg =isp_reg_readl (phy->isp, phy->cfg_regs,ISPCSI2_PHY_CFG );for (i =0 ; i < num_data_lanes; i++) { reg &= ~(ISPCSI2_PHY_CFG_DATA_POL_MASK(i + 1) |@@ -263,12 +258,12 @@ static int omap3isp_csiphy_config(struct isp_csiphy *phy) reg |= lanes->clk.pol << ISPCSI2_PHY_CFG_CLOCK_POL_SHIFT; reg |= lanes->clk.pos <<ISPCSI2_PHY_CFG_CLOCK_POSITION_SHIFT ; -isp_reg_writel (csi2->isp, reg, phy->cfg_regs,ISPCSI2_PHY_CFG ); +isp_reg_writel (phy->isp, reg, phy->cfg_regs,ISPCSI2_PHY_CFG );return 0 ; } -int omap3isp_csiphy_acquire (struct isp_csiphy *phy) +int omap3isp_csiphy_acquire (struct isp_csiphy *phy,struct media_entity *entity) {int rval;@@ -288,6 +283,8 @@ int omap3isp_csiphy_acquire(struct isp_csiphy *phy)if (rval <0 ) goto done; + phy->entity = entity; + rval =omap3isp_csiphy_config (phy);if (rval <0 ) goto done;@@ -301,10 +298,10 @@ int omap3isp_csiphy_acquire(struct isp_csiphy *phy)csiphy_power_autoswitch_enable (phy, true); } - - phy->phy_in_use =1 ; - done: +if (rval <0 ) + phy->entity =NULL ; +mutex_unlock (&phy->mutex);return rval; }@@ -312,10 +309,8 @@ int omap3isp_csiphy_acquire(struct isp_csiphy *phy)void omap3isp_csiphy_release (struct isp_csiphy *phy) {mutex_lock (&phy->mutex); -if (phy->phy_in_use) { -struct isp_csi2_device *csi2 = phy->csi2; -struct isp_pipeline *pipe = -to_isp_pipeline (&csi2->subdev.entity); +if (phy->entity) { +struct isp_pipeline *pipe =to_isp_pipeline (phy->entity);struct isp_bus_cfg *buscfg = pipe->external->host_priv; csiphy_routing_cfg(phy, buscfg->interface, false,@@ -325,7 +320,7 @@ void omap3isp_csiphy_release(struct isp_csiphy *phy)csiphy_set_power (phy,ISPCSI2_PHY_CFG_PWR_CMD_OFF ); }regulator_disable (phy->vdd); - phy->phy_in_use =0 ; + phy->entity =NULL ; }mutex_unlock (&phy->mutex); }(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispcsiphy.hindex978ca5c80a6c..91543a09b28a100644drivers/media/platform/omap3isp/ispcsiphy.h +4
-2@@ -25,9 +25,10 @@ struct regulator;struct isp_csiphy {struct isp_device *isp;struct mutex mutex;/* serialize csiphy configuration */ -u8 phy_in_use;struct isp_csi2_device *csi2;struct regulator *vdd; +/* the entity that acquired the phy */ +struct media_entity *entity;/* mem resources - enums as defined in enum isp_mem_resources */ unsigned int cfg_regs;@@ -36,7 +37,8 @@ struct isp_csiphy {u8 num_data_lanes;/* number of CSI2 Data Lanes supported */ }; -int omap3isp_csiphy_acquire (struct isp_csiphy *phy); +int omap3isp_csiphy_acquire (struct isp_csiphy *phy, +struct media_entity *entity);void omap3isp_csiphy_release (struct isp_csiphy *phy);int omap3isp_csiphy_init (struct isp_device *isp);void omap3isp_csiphy_cleanup (struct isp_device *isp);
Signature · 3 lines
Regards, Laurent Pinchart
PATCH v2 5/5 omap3isp: Correctly configure routing in PHY release
In reply to Sakari AilusThe PHY configuration was obtained from DT when the PHY was acquired but the same was not done when it was released. Fix this.
--- drivers/media/platform/omap3isp/ispcsiphy.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
drivers/media/platform/omap3isp/ispcsiphy.c +13 -6
@@ -155,6 +155,17 @@ static int csiphy_set_power(struct isp_csiphy *phy, u32 power)return 0 ; } +static struct isp_bus_cfg *omap3isp_csiphy_get_phy_cfg ( +struct isp_csiphy *phy) +{ +struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); +struct isp_async_subdev *isd = + container_of(pipe->external->asd, struct isp_async_subdev, asd); + +return pipe->external->host_priv ? + pipe->external->host_priv : &isd->bus; +} +/* * TCLK values are OK at their reset values */
@@ -165,10 +176,7 @@ static int csiphy_set_power(struct isp_csiphy *phy, u32 power)static int omap3isp_csiphy_config (struct isp_csiphy *phy) {struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_async_subdev *isd = - container_of(pipe->external->asd, struct isp_async_subdev, asd); -struct isp_bus_cfg *buscfg = pipe->external->host_priv ? - pipe->external->host_priv : &isd->bus; +struct isp_bus_cfg *buscfg =omap3isp_csiphy_get_phy_cfg (phy);struct isp_csiphy_lanes_cfg *lanes;int csi2_ddrclk_khz;unsigned int num_data_lanes, used_lanes =0 ;
@@ -310,8 +318,7 @@ void omap3isp_csiphy_release(struct isp_csiphy *phy) {mutex_lock (&phy->mutex);if (phy->entity) { -struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_bus_cfg *buscfg = pipe->external->host_priv; +struct isp_bus_cfg *buscfg =omap3isp_csiphy_get_phy_cfg (phy);csiphy_routing_cfg (phy, buscfg->interface, false, buscfg->bus.ccp2.phy_layer);
Signature · 1 line
2.11.0
PATCH v2 5/5 omap3isp: Quit using struct v4l2_subdev.host_priv field
struct v4l2_subdev.host_priv is intended to be used by another driver. This is hardly good design but back in the days of platform data was a quick hack to get things done.
As the sub-device specific bus information can be stored to the ISP driver specific struct allocated along with v4l2_async_subdev, keep the information there and only there.
---
This patch replaces patch "omap3isp: Correctly configure routing in PHY release".
drivers/media/platform/omap3isp/isp.c | 31 +++++++++-------------------- drivers/media/platform/omap3isp/ispccdc.c | 20 ++++++++++++------- drivers/media/platform/omap3isp/ispccp2.c | 4 +++- drivers/media/platform/omap3isp/ispcsi2.c | 3 ++- drivers/media/platform/omap3isp/ispcsiphy.c | 11 +++++----- 5 files changed, 33 insertions(+), 36 deletions(-)
drivers/media/platform/omap3isp/isp.c +9 -22
@@ -2188,26 +2188,12 @@ static int isp_fwnodes_parse(struct device *dev,return -EINVAL ; } -static int isp_subdev_notifier_bound (struct v4l2_async_notifier *async, -struct v4l2_subdev *subdev, -struct v4l2_async_subdev *asd) -{ -struct isp_async_subdev *isd = - container_of(asd, struct isp_async_subdev, asd); - - isd->sd = subdev; - isd->sd->host_priv = &isd->bus; - -return 0 ; -} -static int isp_subdev_notifier_complete (struct v4l2_async_notifier *async) { struct isp_device *isp = container_of(async, struct isp_device, notifier);struct v4l2_device *v4l2_dev = &isp->v4l2_dev;struct v4l2_subdev *sd; -struct isp_bus_cfg *bus;int ret; ret =media_entity_enum_init (&isp->crashed, &isp->media_dev);
@@ -2215,13 +2201,15 @@ static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async)return ret;list_for_each_entry (sd, &v4l2_dev->subdevs, list) { -/* Only try to link entities whose interface was set on bound */ -if (sd->host_priv) { - bus = (struct isp_bus_cfg *)sd->host_priv; - ret =isp_link_entity (isp, &sd->entity, bus->interface); -if (ret <0 ) -return ret; - } +struct isp_async_subdev *isd; + +if (!sd->asd) +continue ; + + isd = container_of(sd->asd, struct isp_async_subdev, asd); + ret =isp_link_entity (isp, &sd->entity, isd->bus.interface); +if (ret <0 ) +return ret; } ret =v4l2_device_register_subdev_nodes (&isp->v4l2_dev);
@@ -2399,7 +2387,6 @@ static int isp_probe(struct platform_device *pdev)if (ret <0 ) goto error_register_entities; - isp->notifier.bound = isp_subdev_notifier_bound; isp->notifier.complete = isp_subdev_notifier_complete; ret =v4l2_async_notifier_register (&isp->v4l2_dev, &isp->notifier);
drivers/media/platform/omap3isp/ispccdc.c +13 -7
@@ -1139,8 +1139,12 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) pad =media_entity_remote_pad (&ccdc->pads[CCDC_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity);if (ccdc->input ==CCDC_INPUT_PARALLEL ) { - parcfg = &((struct isp_bus_cfg *)sensor->host_priv) - ->bus.parallel; +struct isp_pipeline *pipe = +to_isp_pipeline (&ccdc->subdev.entity); + + parcfg = &container_of (pipe->external->asd, + struct isp_async_subdev, + asd)->bus.bus.parallel; ccdc->bt656 = parcfg->bt656; }
@@ -2412,11 +2416,13 @@ static int ccdc_link_validate(struct v4l2_subdev *sd,/* We've got a parallel sensor here. */ if (ccdc->input ==CCDC_INPUT_PARALLEL ) { -struct isp_parallel_cfg *parcfg = - &((struct isp_bus_cfg *) -media_entity_to_v4l2_subdev (link->source->entity) - ->host_priv)->bus.parallel; - parallel_shift = parcfg->data_lane_shift; +struct isp_pipeline *pipe = +to_isp_pipeline (&ccdc->subdev.entity); + + parallel_shift = +container_of (pipe->external->asd, + struct isp_async_subdev, + asd)->bus.bus.parallel.data_lane_shift; }else { parallel_shift =0 ; }
drivers/media/platform/omap3isp/ispccp2.c +3 -1
@@ -350,6 +350,7 @@ static void ccp2_lcx_config(struct isp_ccp2_device *ccp2,*/ static int ccp2_if_configure (struct isp_ccp2_device *ccp2) { +struct isp_pipeline *pipe =to_isp_pipeline (&ccp2->subdev.entity);const struct isp_bus_cfg *buscfg;struct v4l2_mbus_framefmt *format;struct media_pad *pad;
@@ -361,7 +362,8 @@ static int ccp2_if_configure(struct isp_ccp2_device *ccp2) pad =media_entity_remote_pad (&ccp2->pads[CCP2_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity); - buscfg = sensor->host_priv; + buscfg = &container_of (pipe->external->asd, + struct isp_async_subdev, asd)->bus; ret =ccp2_phyif_config (ccp2, &buscfg->bus.ccp2);if (ret <0 )
drivers/media/platform/omap3isp/ispcsi2.c +2 -1
@@ -566,7 +566,8 @@ static int csi2_configure(struct isp_csi2_device *csi2) pad =media_entity_remote_pad (&csi2->pads[CSI2_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity); - buscfg = sensor->host_priv; + buscfg = &container_of (pipe->external->asd, + struct isp_async_subdev, asd)->bus; csi2->frame_skip =0 ;v4l2_subdev_call (sensor, sensor, g_skip_frames, &csi2->frame_skip);
drivers/media/platform/omap3isp/ispcsiphy.c +6 -5
@@ -165,10 +165,9 @@ static int csiphy_set_power(struct isp_csiphy *phy, u32 power)static int omap3isp_csiphy_config (struct isp_csiphy *phy) {struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_async_subdev *isd = - container_of(pipe->external->asd, struct isp_async_subdev, asd); -struct isp_bus_cfg *buscfg = pipe->external->host_priv ? - pipe->external->host_priv : &isd->bus; +struct isp_bus_cfg *buscfg = + &container_of (pipe->external->asd, + struct isp_async_subdev, asd)->bus;struct isp_csiphy_lanes_cfg *lanes;int csi2_ddrclk_khz;unsigned int num_data_lanes, used_lanes =0 ;
@@ -311,7 +310,9 @@ void omap3isp_csiphy_release(struct isp_csiphy *phy)mutex_lock (&phy->mutex);if (phy->entity) {struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_bus_cfg *buscfg = pipe->external->host_priv; +struct isp_bus_cfg *buscfg = + &container_of (pipe->external->asd, + struct isp_async_subdev, asd)->bus;csiphy_routing_cfg (phy, buscfg->interface, false, buscfg->bus.ccp2.phy_layer);
Signature · 1 line
2.11.0
PATCH v2 5/5 omap3isp: Quit using struct v4l2_subdev.host_priv field
struct v4l2_subdev.host_priv is intended to be used by another driver. This is hardly good design but back in the days of platform data was a quick hack to get things done.
As the sub-device specific bus information can be stored to the ISP driver specific struct allocated along with v4l2_async_subdev, keep the information there and only there.
---
since v2.1:
- Remove struct isp_async_subdev.sd field as it is now redundant.
drivers/media/platform/omap3isp/isp.c | 31 +++++++++-------------------- drivers/media/platform/omap3isp/isp.h | 1 - drivers/media/platform/omap3isp/ispccdc.c | 20 ++++++++++++------- drivers/media/platform/omap3isp/ispccp2.c | 4 +++- drivers/media/platform/omap3isp/ispcsi2.c | 3 ++- drivers/media/platform/omap3isp/ispcsiphy.c | 11 +++++----- 6 files changed, 33 insertions(+), 37 deletions(-)
drivers/media/platform/omap3isp/isp.c +9 -22
@@ -2188,26 +2188,12 @@ static int isp_fwnodes_parse(struct device *dev,return -EINVAL ; } -static int isp_subdev_notifier_bound (struct v4l2_async_notifier *async, -struct v4l2_subdev *subdev, -struct v4l2_async_subdev *asd) -{ -struct isp_async_subdev *isd = - container_of(asd, struct isp_async_subdev, asd); - - isd->sd = subdev; - isd->sd->host_priv = &isd->bus; - -return 0 ; -} -static int isp_subdev_notifier_complete (struct v4l2_async_notifier *async) { struct isp_device *isp = container_of(async, struct isp_device, notifier);struct v4l2_device *v4l2_dev = &isp->v4l2_dev;struct v4l2_subdev *sd; -struct isp_bus_cfg *bus;int ret; ret =media_entity_enum_init (&isp->crashed, &isp->media_dev);
@@ -2215,13 +2201,15 @@ static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async)return ret;list_for_each_entry (sd, &v4l2_dev->subdevs, list) { -/* Only try to link entities whose interface was set on bound */ -if (sd->host_priv) { - bus = (struct isp_bus_cfg *)sd->host_priv; - ret =isp_link_entity (isp, &sd->entity, bus->interface); -if (ret <0 ) -return ret; - } +struct isp_async_subdev *isd; + +if (!sd->asd) +continue ; + + isd = container_of(sd->asd, struct isp_async_subdev, asd); + ret =isp_link_entity (isp, &sd->entity, isd->bus.interface); +if (ret <0 ) +return ret; } ret =v4l2_device_register_subdev_nodes (&isp->v4l2_dev);
@@ -2399,7 +2387,6 @@ static int isp_probe(struct platform_device *pdev)if (ret <0 ) goto error_register_entities; - isp->notifier.bound = isp_subdev_notifier_bound; isp->notifier.complete = isp_subdev_notifier_complete; ret =v4l2_async_notifier_register (&isp->v4l2_dev, &isp->notifier);
drivers/media/platform/omap3isp/isp.h +0 -1
@@ -226,7 +226,6 @@ struct isp_device { };struct isp_async_subdev { -struct v4l2_subdev *sd;struct isp_bus_cfg bus;struct v4l2_async_subdev asd; };
drivers/media/platform/omap3isp/ispccdc.c +13 -7
@@ -1139,8 +1139,12 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) pad =media_entity_remote_pad (&ccdc->pads[CCDC_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity);if (ccdc->input ==CCDC_INPUT_PARALLEL ) { - parcfg = &((struct isp_bus_cfg *)sensor->host_priv) - ->bus.parallel; +struct isp_pipeline *pipe = +to_isp_pipeline (&ccdc->subdev.entity); + + parcfg = &container_of (pipe->external->asd, + struct isp_async_subdev, + asd)->bus.bus.parallel; ccdc->bt656 = parcfg->bt656; }
@@ -2412,11 +2416,13 @@ static int ccdc_link_validate(struct v4l2_subdev *sd,/* We've got a parallel sensor here. */ if (ccdc->input ==CCDC_INPUT_PARALLEL ) { -struct isp_parallel_cfg *parcfg = - &((struct isp_bus_cfg *) -media_entity_to_v4l2_subdev (link->source->entity) - ->host_priv)->bus.parallel; - parallel_shift = parcfg->data_lane_shift; +struct isp_pipeline *pipe = +to_isp_pipeline (&ccdc->subdev.entity); + + parallel_shift = +container_of (pipe->external->asd, + struct isp_async_subdev, + asd)->bus.bus.parallel.data_lane_shift; }else { parallel_shift =0 ; }
drivers/media/platform/omap3isp/ispccp2.c +3 -1
@@ -350,6 +350,7 @@ static void ccp2_lcx_config(struct isp_ccp2_device *ccp2,*/ static int ccp2_if_configure (struct isp_ccp2_device *ccp2) { +struct isp_pipeline *pipe =to_isp_pipeline (&ccp2->subdev.entity);const struct isp_bus_cfg *buscfg;struct v4l2_mbus_framefmt *format;struct media_pad *pad;
@@ -361,7 +362,8 @@ static int ccp2_if_configure(struct isp_ccp2_device *ccp2) pad =media_entity_remote_pad (&ccp2->pads[CCP2_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity); - buscfg = sensor->host_priv; + buscfg = &container_of (pipe->external->asd, + struct isp_async_subdev, asd)->bus; ret =ccp2_phyif_config (ccp2, &buscfg->bus.ccp2);if (ret <0 )
drivers/media/platform/omap3isp/ispcsi2.c +2 -1
@@ -566,7 +566,8 @@ static int csi2_configure(struct isp_csi2_device *csi2) pad =media_entity_remote_pad (&csi2->pads[CSI2_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity); - buscfg = sensor->host_priv; + buscfg = &container_of (pipe->external->asd, + struct isp_async_subdev, asd)->bus; csi2->frame_skip =0 ;v4l2_subdev_call (sensor, sensor, g_skip_frames, &csi2->frame_skip);
drivers/media/platform/omap3isp/ispcsiphy.c +6 -5
@@ -165,10 +165,9 @@ static int csiphy_set_power(struct isp_csiphy *phy, u32 power)static int omap3isp_csiphy_config (struct isp_csiphy *phy) {struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_async_subdev *isd = - container_of(pipe->external->asd, struct isp_async_subdev, asd); -struct isp_bus_cfg *buscfg = pipe->external->host_priv ? - pipe->external->host_priv : &isd->bus; +struct isp_bus_cfg *buscfg = + &container_of (pipe->external->asd, + struct isp_async_subdev, asd)->bus;struct isp_csiphy_lanes_cfg *lanes;int csi2_ddrclk_khz;unsigned int num_data_lanes, used_lanes =0 ;
@@ -311,7 +310,9 @@ void omap3isp_csiphy_release(struct isp_csiphy *phy)mutex_lock (&phy->mutex);if (phy->entity) {struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_bus_cfg *buscfg = pipe->external->host_priv; +struct isp_bus_cfg *buscfg = + &container_of (pipe->external->asd, + struct isp_async_subdev, asd)->bus;csiphy_routing_cfg (phy, buscfg->interface, false, buscfg->bus.ccp2.phy_layer);
Signature · 1 line
2.11.0
Re: [PATCH v2.2 5/5] omap3isp: Quit using struct v4l2_subdev.host_priv field
Hi Sakari,
Thank you for the patch.
Quoted 9 lines · On Wednesday 16 Aug 2017 20:05:52 Sakari Ailus wrote:
struct v4l2_subdev.host_priv is intended to be used by another driver. This is hardly good design but back in the days of platform data was a quick hack to get things done.
As the sub-device specific bus information can be stored to the ISP driver specific struct allocated along with
v4l2_async_subdev, keep the information there and only there.Signed-off-by Sakari Ailus <[email protected]>
This looks better to me than the previous approach. Please see below for one last comment.
Quoted 46 lines
---
since v2.1:- Remove struct isp_async_subdev.sd field as it is now redundant.
drivers/media/platform/omap3isp/isp.c | 31 ++++++++------------------ drivers/media/platform/omap3isp/isp.h | 1 - drivers/media/platform/omap3isp/ispccdc.c | 20 ++++++++++++------- drivers/media/platform/omap3isp/ispccp2.c | 4 +++- drivers/media/platform/omap3isp/ispcsi2.c | 3 ++- drivers/media/platform/omap3isp/ispcsiphy.c | 11 +++++----- 6 files changed, 33 insertions(+), 37 deletions(-)(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/isp.cindex6cb1f0495804..27c577fac8e9100644drivers/media/platform/omap3isp/isp.c +0
-14@@ -2188,26 +2188,12 @@ static int isp_fwnodes_parse(struct device *dev,return -EINVAL ; } -static int isp_subdev_notifier_bound (struct v4l2_async_notifier *async, -struct v4l2_subdev *subdev, -struct v4l2_async_subdev *asd) -{ -struct isp_async_subdev *isd = - container_of(asd, struct isp_async_subdev, asd); - - isd->sd = subdev; - isd->sd->host_priv = &isd->bus; - -return 0 ; -} -static int isp_subdev_notifier_complete (struct v4l2_async_notifier *async) { struct isp_device *isp = container_of(async, struct isp_device, notifier);struct v4l2_device *v4l2_dev = &isp->v4l2_dev;struct v4l2_subdev *sd; -struct isp_bus_cfg *bus;int ret; ret =media_entity_enum_init (&isp->crashed, &isp->media_dev);
drivers/media/platform/omap3isp/isp.c static int isp_subdev_notifier_complete(struct · line 2218
Quoted 4 lines
drivers/media/platform/omap3isp/isp.c +0
-1@@ -2215,13 +2201,15 @@ static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async) return ret;list_for_each_entry (sd, &v4l2_dev->subdevs, list) { -/* Only try to link entities whose interface was set on bound
*/
Quoted 47 lines
drivers/media/platform/omap3isp/isp.c +9
-6-if (sd->host_priv) { - bus = (struct isp_bus_cfg *)sd->host_priv; - ret =isp_link_entity (isp, &sd->entity, bus- interface); -if (ret <0 ) -return ret; - } +struct isp_async_subdev *isd; + +if (!sd->asd) +continue ; + + isd = container_of(sd->asd, struct isp_async_subdev, asd); + ret =isp_link_entity (isp, &sd->entity, isd->bus.interface); +if (ret <0 ) +return ret; }drivers/media/platform/omap3isp/isp.c +0
-1ret =v4l2_device_register_subdev_nodes (&isp->v4l2_dev);@@ -2399,7 +2387,6 @@ static int isp_probe(struct platform_device *pdev)if (ret <0 ) goto error_register_entities; - isp->notifier.bound = isp_subdev_notifier_bound; isp->notifier.complete = isp_subdev_notifier_complete; ret =v4l2_async_notifier_register (&isp->v4l2_dev, &isp->notifier);(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/isp.hindex2f2ae609c548..25472c81dcdd100644drivers/media/platform/omap3isp/isp.h +0
-1@@ -226,7 +226,6 @@ struct isp_device { };struct isp_async_subdev { -struct v4l2_subdev *sd;struct isp_bus_cfg bus;struct v4l2_async_subdev asd; };(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispccdc.cindex4947876cfadf..0145b3dcd7a7100644drivers/media/platform/omap3isp/ispccdc.c +0
-0@@ -1139,8 +1139,12 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) pad = media_entity_remote_pad(&ccdc->pads[CCDC_PAD_SINK]);
drivers/media/platform/omap3isp/ispccdc.c static void ccdc_configure(struct isp_ccdc_device · line 1147
Quoted 10 lines
drivers/media/platform/omap3isp/ispccdc.c +6
-2sensor =media_entity_to_v4l2_subdev (pad->entity);if (ccdc->input ==CCDC_INPUT_PARALLEL ) { - parcfg = &((struct isp_bus_cfg *)sensor->host_priv) - ->bus.parallel; +struct isp_pipeline *pipe = +to_isp_pipeline (&ccdc->subdev.entity); + + parcfg = &container_of (pipe->external->asd, + struct isp_async_subdev, + asd)->bus.bus.parallel;
You use this construct in many places, how about adding
struct isp_bus_cfg *to_bus_cfg(struct v4l2_subdev *sd)
{
return &container_of(sd->asd, struct isp_async_subdev, asd)->bus;
}or possibly a macro to handle the const/non-const cases.
Quoted 68 lines
drivers/media/platform/omap3isp/ispccdc.c +7
-5ccdc->bt656 = parcfg->bt656; }@@ -2412,11 +2416,13 @@ static int ccdc_link_validate(struct v4l2_subdev *sd,/* We've got a parallel sensor here. */ if (ccdc->input ==CCDC_INPUT_PARALLEL ) { -struct isp_parallel_cfg *parcfg = - &((struct isp_bus_cfg *) -media_entity_to_v4l2_subdev (link->source->entity) - ->host_priv)->bus.parallel; - parallel_shift = parcfg->data_lane_shift; +struct isp_pipeline *pipe = +to_isp_pipeline (&ccdc->subdev.entity); + + parallel_shift = +container_of (pipe->external->asd, + struct isp_async_subdev, + asd)->bus.bus.parallel.data_lane_shift; }else { parallel_shift =0 ;drivers/media/platform/omap3isp/ispccdc.c +0
-0}(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispccp2.cindex3db8df09cd9a..8561c4e4c5ac100644drivers/media/platform/omap3isp/ispccp2.c +3
-1@@ -350,6 +350,7 @@ static void ccp2_lcx_config(struct isp_ccp2_device*ccp2, */ static int ccp2_if_configure (struct isp_ccp2_device *ccp2) { +struct isp_pipeline *pipe =to_isp_pipeline (&ccp2->subdev.entity);const struct isp_bus_cfg *buscfg;struct v4l2_mbus_framefmt *format;struct media_pad *pad;@@ -361,7 +362,8 @@ static int ccp2_if_configure(struct isp_ccp2_device *ccp2) pad =media_entity_remote_pad (&ccp2->pads[CCP2_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity); - buscfg = sensor->host_priv; + buscfg = &container_of (pipe->external->asd, + struct isp_async_subdev, asd)->bus; ret =ccp2_phyif_config (ccp2, &buscfg->bus.ccp2);drivers/media/platform/omap3isp/ispccp2.c +0
-0if (ret <0 )(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispcsi2.cindex3ec37fed710b..2802f70fc8b3100644drivers/media/platform/omap3isp/ispcsi2.c +2
-1@@ -566,7 +566,8 @@ static int csi2_configure(struct isp_csi2_device *csi2) pad =media_entity_remote_pad (&csi2->pads[CSI2_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity); - buscfg = sensor->host_priv; + buscfg = &container_of (pipe->external->asd, + struct isp_async_subdev, asd)->bus; csi2->frame_skip =0 ;v4l2_subdev_call (sensor, sensor, g_skip_frames, &csi2->frame_skip);(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispcsiphy.cindexed1eb9907ae0..ef79bf37c2dd100644
drivers/media/platform/omap3isp/ispcsiphy.c static int csiphy_set_power(struct isp_csiphy *phy, u32 · line 169
Quoted 5 lines
drivers/media/platform/omap3isp/ispcsiphy.c +0
-2@@ -165,10 +165,9 @@ static int csiphy_set_power(struct isp_csiphy *phy, u32 power) static int omap3isp_csiphy_config(struct isp_csiphy *phy) {struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_async_subdev *isd = - container_of(pipe->external->asd, struct isp_async_subdev,
asd);
Quoted 19 lines
drivers/media/platform/omap3isp/ispcsiphy.c +6
-3-struct isp_bus_cfg *buscfg = pipe->external->host_priv ? - pipe->external->host_priv : &isd->bus; +struct isp_bus_cfg *buscfg = + &container_of (pipe->external->asd, + struct isp_async_subdev, asd)->bus;struct isp_csiphy_lanes_cfg *lanes;int csi2_ddrclk_khz;unsigned int num_data_lanes, used_lanes =0 ;@@ -311,7 +310,9 @@ void omap3isp_csiphy_release(struct isp_csiphy *phy)mutex_lock (&phy->mutex);if (phy->entity) {struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_bus_cfg *buscfg = pipe->external->host_priv; +struct isp_bus_cfg *buscfg = + &container_of (pipe->external->asd, + struct isp_async_subdev, asd)->bus;csiphy_routing_cfg (phy, buscfg->interface, false, buscfg->bus.ccp2.phy_layer);
Signature · 3 lines
Regards, Laurent Pinchart
Re: [PATCH v2.2 5/5] omap3isp: Quit using struct v4l2_subdev.host_priv field
Quoted 129 lines · Laurent Pinchart
Hi Sakari,
Thank you for the patch.
Quoted 9 lines · On Wednesday 16 Aug 2017 20:05:52 Sakari Ailus wrote:
struct v4l2_subdev.host_priv is intended to be used by another driver. This is hardly good design but back in the days of platform data was a quick hack to get things done.
As the sub-device specific bus information can be stored to the ISP driver specific struct allocated along with
v4l2_async_subdev, keep the information there and only there.Signed-off-by Sakari Ailus <[email protected]>This looks better to me than the previous approach. Please see below for one last comment.
Quoted 46 lines
---
since v2.1:- Remove struct isp_async_subdev.sd field as it is now redundant.
drivers/media/platform/omap3isp/isp.c | 31 ++++++++------------------ drivers/media/platform/omap3isp/isp.h | 1 - drivers/media/platform/omap3isp/ispccdc.c | 20 ++++++++++++------- drivers/media/platform/omap3isp/ispccp2.c | 4 +++- drivers/media/platform/omap3isp/ispcsi2.c | 3 ++- drivers/media/platform/omap3isp/ispcsiphy.c | 11 +++++----- 6 files changed, 33 insertions(+), 37 deletions(-)(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/isp.cindex6cb1f0495804..27c577fac8e9100644drivers/media/platform/omap3isp/isp.c +0
-14@@ -2188,26 +2188,12 @@ static int isp_fwnodes_parse(struct device *dev,return -EINVAL ; } -static int isp_subdev_notifier_bound (struct v4l2_async_notifier *async, -struct v4l2_subdev *subdev, -struct v4l2_async_subdev *asd) -{ -struct isp_async_subdev *isd = - container_of(asd, struct isp_async_subdev, asd); - - isd->sd = subdev; - isd->sd->host_priv = &isd->bus; - -return 0 ; -} -static int isp_subdev_notifier_complete (struct v4l2_async_notifier *async) { struct isp_device *isp = container_of(async, struct isp_device, notifier);struct v4l2_device *v4l2_dev = &isp->v4l2_dev;struct v4l2_subdev *sd; -struct isp_bus_cfg *bus;int ret; ret =media_entity_enum_init (&isp->crashed, &isp->media_dev);drivers/media/platform/omap3isp/isp.c static int isp_subdev_notifier_complete(struct · line 2218
Quoted 4 lines
drivers/media/platform/omap3isp/isp.c +0
-1@@ -2215,13 +2201,15 @@ static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async) return ret;list_for_each_entry (sd, &v4l2_dev->subdevs, list) { -/* Only try to link entities whose interface was set on bound */
Quoted 47 lines
drivers/media/platform/omap3isp/isp.c +9
-6-if (sd->host_priv) { - bus = (struct isp_bus_cfg *)sd->host_priv; - ret =isp_link_entity (isp, &sd->entity, bus- interface); -if (ret <0 ) -return ret; - } +struct isp_async_subdev *isd; + +if (!sd->asd) +continue ; + + isd = container_of(sd->asd, struct isp_async_subdev, asd); + ret =isp_link_entity (isp, &sd->entity, isd->bus.interface); +if (ret <0 ) +return ret; }drivers/media/platform/omap3isp/isp.c +0
-1ret =v4l2_device_register_subdev_nodes (&isp->v4l2_dev);@@ -2399,7 +2387,6 @@ static int isp_probe(struct platform_device *pdev)if (ret <0 ) goto error_register_entities; - isp->notifier.bound = isp_subdev_notifier_bound; isp->notifier.complete = isp_subdev_notifier_complete; ret =v4l2_async_notifier_register (&isp->v4l2_dev, &isp->notifier);(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/isp.hindex2f2ae609c548..25472c81dcdd100644drivers/media/platform/omap3isp/isp.h +0
-1@@ -226,7 +226,6 @@ struct isp_device { };struct isp_async_subdev { -struct v4l2_subdev *sd;struct isp_bus_cfg bus;struct v4l2_async_subdev asd; };(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispccdc.cindex4947876cfadf..0145b3dcd7a7100644drivers/media/platform/omap3isp/ispccdc.c +0
-0@@ -1139,8 +1139,12 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) pad = media_entity_remote_pad(&ccdc->pads[CCDC_PAD_SINK]);drivers/media/platform/omap3isp/ispccdc.c static void ccdc_configure(struct isp_ccdc_device · line 1147
Quoted 10 lines
drivers/media/platform/omap3isp/ispccdc.c +6
-2sensor =media_entity_to_v4l2_subdev (pad->entity);if (ccdc->input ==CCDC_INPUT_PARALLEL ) { - parcfg = &((struct isp_bus_cfg *)sensor->host_priv) - ->bus.parallel; +struct isp_pipeline *pipe = +to_isp_pipeline (&ccdc->subdev.entity); + + parcfg = &container_of (pipe->external->asd, + struct isp_async_subdev, + asd)->bus.bus.parallel;You use this construct in many places, how about adding
Quoted 6 lines
struct
isp_bus_cfg*to_bus_cfg(structv4l2_subdev*sd){ return &container_of(sd->asd, struct isp_async_subdev, asd)->bus; }or possibly a macro to handle the const/non-const cases.
I'll add that and send v2.3.
Quoted 100 lines
Quoted 69 lines
drivers/media/platform/omap3isp/ispccdc.c +7
-5ccdc->bt656 = parcfg->bt656; }@@ -2412,11 +2416,13 @@ static int ccdc_link_validate(struct v4l2_subdev *sd,/* We've got a parallel sensor here. */ if (ccdc->input ==CCDC_INPUT_PARALLEL ) { -struct isp_parallel_cfg *parcfg = - &((struct isp_bus_cfg *) -media_entity_to_v4l2_subdev (link->source->entity) - ->host_priv)->bus.parallel; - parallel_shift = parcfg->data_lane_shift; +struct isp_pipeline *pipe = +to_isp_pipeline (&ccdc->subdev.entity); + + parallel_shift = +container_of (pipe->external->asd, + struct isp_async_subdev, + asd)->bus.bus.parallel.data_lane_shift; }else { parallel_shift =0 ;drivers/media/platform/omap3isp/ispccdc.c +0
-0}(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispccp2.cindex3db8df09cd9a..8561c4e4c5ac100644drivers/media/platform/omap3isp/ispccp2.c +3
-1@@ -350,6 +350,7 @@ static void ccp2_lcx_config(struct isp_ccp2_device*ccp2, */ static int ccp2_if_configure (struct isp_ccp2_device *ccp2) { +struct isp_pipeline *pipe =to_isp_pipeline (&ccp2->subdev.entity);const struct isp_bus_cfg *buscfg;struct v4l2_mbus_framefmt *format;struct media_pad *pad;@@ -361,7 +362,8 @@ static int ccp2_if_configure(struct isp_ccp2_device *ccp2) pad =media_entity_remote_pad (&ccp2->pads[CCP2_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity); - buscfg = sensor->host_priv; + buscfg = &container_of (pipe->external->asd, + struct isp_async_subdev, asd)->bus; ret =ccp2_phyif_config (ccp2, &buscfg->bus.ccp2);drivers/media/platform/omap3isp/ispccp2.c +0
-0if (ret <0 )(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispcsi2.cindex3ec37fed710b..2802f70fc8b3100644drivers/media/platform/omap3isp/ispcsi2.c +2
-1@@ -566,7 +566,8 @@ static int csi2_configure(struct isp_csi2_device *csi2) pad =media_entity_remote_pad (&csi2->pads[CSI2_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity); - buscfg = sensor->host_priv; + buscfg = &container_of (pipe->external->asd, + struct isp_async_subdev, asd)->bus; csi2->frame_skip =0 ;v4l2_subdev_call (sensor, sensor, g_skip_frames, &csi2->frame_skip);(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispcsiphy.cindexed1eb9907ae0..ef79bf37c2dd100644drivers/media/platform/omap3isp/ispcsiphy.c static int csiphy_set_power(struct isp_csiphy *phy, u32 · line 169
Quoted 5 lines
drivers/media/platform/omap3isp/ispcsiphy.c +0
-2@@ -165,10 +165,9 @@ static int csiphy_set_power(struct isp_csiphy *phy, u32 power) static int omap3isp_csiphy_config(struct isp_csiphy *phy) {struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_async_subdev *isd = - container_of(pipe->external->asd, struct isp_async_subdev,asd);
Quoted 19 lines
drivers/media/platform/omap3isp/ispcsiphy.c +6
-3-struct isp_bus_cfg *buscfg = pipe->external->host_priv ? - pipe->external->host_priv : &isd->bus; +struct isp_bus_cfg *buscfg = + &container_of (pipe->external->asd, + struct isp_async_subdev, asd)->bus;struct isp_csiphy_lanes_cfg *lanes;int csi2_ddrclk_khz;unsigned int num_data_lanes, used_lanes =0 ;@@ -311,7 +310,9 @@ void omap3isp_csiphy_release(struct isp_csiphy *phy)mutex_lock (&phy->mutex);if (phy->entity) {struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_bus_cfg *buscfg = pipe->external->host_priv; +struct isp_bus_cfg *buscfg = + &container_of (pipe->external->asd, + struct isp_async_subdev, asd)->bus;csiphy_routing_cfg (phy, buscfg->interface, false, buscfg->bus.ccp2.phy_layer);Signature · 3 lines
Regards, Laurent Pinchart
Signature · 2 lines
Sakari Ailus e-mail: [email protected]
PATCH v2 5/5 omap3isp: Quit using struct v4l2_subdev.host_priv field
In reply to Laurent Pinchartstruct v4l2_subdev.host_priv is intended to be used by another driver. This is hardly good design but back in the days of platform data was a quick hack to get things done.
As the sub-device specific bus information can be stored to the ISP driver specific struct allocated along with v4l2_async_subdev, keep the information there and only there.
---
since v2.2:
- Introduce a macro v4l2_subdev_to_bus_cfg() in order to remove non-trivial usage in places where conversion from sub-device to ISP bus configuration is needed.
drivers/media/platform/omap3isp/isp.c | 29 +++++++---------------------- drivers/media/platform/omap3isp/isp.h | 4 +++- drivers/media/platform/omap3isp/ispccdc.c | 12 ++++++------ drivers/media/platform/omap3isp/ispccp2.c | 3 ++- drivers/media/platform/omap3isp/ispcsi2.c | 2 +- drivers/media/platform/omap3isp/ispcsiphy.c | 8 +++----- 6 files changed, 22 insertions(+), 36 deletions(-)
drivers/media/platform/omap3isp/isp.c +7 -22
@@ -2188,26 +2188,12 @@ static int isp_fwnodes_parse(struct device *dev,return -EINVAL ; } -static int isp_subdev_notifier_bound (struct v4l2_async_notifier *async, -struct v4l2_subdev *subdev, -struct v4l2_async_subdev *asd) -{ -struct isp_async_subdev *isd = - container_of(asd, struct isp_async_subdev, asd); - - isd->sd = subdev; - isd->sd->host_priv = &isd->bus; - -return 0 ; -} -static int isp_subdev_notifier_complete (struct v4l2_async_notifier *async) { struct isp_device *isp = container_of(async, struct isp_device, notifier);struct v4l2_device *v4l2_dev = &isp->v4l2_dev;struct v4l2_subdev *sd; -struct isp_bus_cfg *bus;int ret; ret =media_entity_enum_init (&isp->crashed, &isp->media_dev);
@@ -2215,13 +2201,13 @@ static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async)return ret;list_for_each_entry (sd, &v4l2_dev->subdevs, list) { -/* Only try to link entities whose interface was set on bound */ -if (sd->host_priv) { - bus = (struct isp_bus_cfg *)sd->host_priv; - ret =isp_link_entity (isp, &sd->entity, bus->interface); -if (ret <0 ) -return ret; - } +if (!sd->asd) +continue ; + + ret =isp_link_entity (isp, &sd->entity, +v4l2_subdev_to_bus_cfg (sd)->interface); +if (ret <0 ) +return ret; } ret =v4l2_device_register_subdev_nodes (&isp->v4l2_dev);
@@ -2399,7 +2385,6 @@ static int isp_probe(struct platform_device *pdev)if (ret <0 ) goto error_register_entities; - isp->notifier.bound = isp_subdev_notifier_bound; isp->notifier.complete = isp_subdev_notifier_complete; ret =v4l2_async_notifier_register (&isp->v4l2_dev, &isp->notifier);
drivers/media/platform/omap3isp/isp.h +3 -1
@@ -226,11 +226,13 @@ struct isp_device { };struct isp_async_subdev { -struct v4l2_subdev *sd;struct isp_bus_cfg bus;struct v4l2_async_subdev asd; }; +#define v4l2_subdev_to_bus_cfg (sd) \ + (&container_of((sd)->asd, struct isp_async_subdev, asd)->bus) +#define v4l2_dev_to_isp_device (dev) \ container_of(dev, struct isp_device, v4l2_dev)
drivers/media/platform/omap3isp/ispccdc.c +6 -6
@@ -1139,7 +1139,8 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) pad =media_entity_remote_pad (&ccdc->pads[CCDC_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity);if (ccdc->input ==CCDC_INPUT_PARALLEL ) { - parcfg = &((struct isp_bus_cfg *)sensor->host_priv) + parcfg = &v4l2_subdev_to_bus_cfg ( +to_isp_pipeline (&ccdc->subdev.entity)->external) ->bus.parallel; ccdc->bt656 = parcfg->bt656; }
@@ -2412,11 +2413,10 @@ static int ccdc_link_validate(struct v4l2_subdev *sd,/* We've got a parallel sensor here. */ if (ccdc->input ==CCDC_INPUT_PARALLEL ) { -struct isp_parallel_cfg *parcfg = - &((struct isp_bus_cfg *) -media_entity_to_v4l2_subdev (link->source->entity) - ->host_priv)->bus.parallel; - parallel_shift = parcfg->data_lane_shift; + parallel_shift = +v4l2_subdev_to_bus_cfg ( +to_isp_pipeline (&ccdc->subdev.entity)->external) + ->bus.parallel.data_lane_shift; }else { parallel_shift =0 ; }
drivers/media/platform/omap3isp/ispccp2.c +2 -1
@@ -350,6 +350,7 @@ static void ccp2_lcx_config(struct isp_ccp2_device *ccp2,*/ static int ccp2_if_configure (struct isp_ccp2_device *ccp2) { +struct isp_pipeline *pipe =to_isp_pipeline (&ccp2->subdev.entity);const struct isp_bus_cfg *buscfg;struct v4l2_mbus_framefmt *format;struct media_pad *pad;
@@ -361,7 +362,7 @@ static int ccp2_if_configure(struct isp_ccp2_device *ccp2) pad =media_entity_remote_pad (&ccp2->pads[CCP2_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity); - buscfg = sensor->host_priv; + buscfg =v4l2_subdev_to_bus_cfg (pipe->external); ret =ccp2_phyif_config (ccp2, &buscfg->bus.ccp2);if (ret <0 )
drivers/media/platform/omap3isp/ispcsi2.c +1 -1
@@ -566,7 +566,7 @@ static int csi2_configure(struct isp_csi2_device *csi2) pad =media_entity_remote_pad (&csi2->pads[CSI2_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity); - buscfg = sensor->host_priv; + buscfg =v4l2_subdev_to_bus_cfg (pipe->external); csi2->frame_skip =0 ;v4l2_subdev_call (sensor, sensor, g_skip_frames, &csi2->frame_skip);
drivers/media/platform/omap3isp/ispcsiphy.c +3 -5
@@ -165,10 +165,7 @@ static int csiphy_set_power(struct isp_csiphy *phy, u32 power)static int omap3isp_csiphy_config (struct isp_csiphy *phy) {struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_async_subdev *isd = - container_of(pipe->external->asd, struct isp_async_subdev, asd); -struct isp_bus_cfg *buscfg = pipe->external->host_priv ? - pipe->external->host_priv : &isd->bus; +struct isp_bus_cfg *buscfg =v4l2_subdev_to_bus_cfg (pipe->external);struct isp_csiphy_lanes_cfg *lanes;int csi2_ddrclk_khz;unsigned int num_data_lanes, used_lanes =0 ;
@@ -311,7 +308,8 @@ void omap3isp_csiphy_release(struct isp_csiphy *phy)mutex_lock (&phy->mutex);if (phy->entity) {struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_bus_cfg *buscfg = pipe->external->host_priv; +struct isp_bus_cfg *buscfg = +v4l2_subdev_to_bus_cfg (pipe->external);csiphy_routing_cfg (phy, buscfg->interface, false, buscfg->bus.ccp2.phy_layer);
Signature · 1 line
2.11.0
Re: [PATCH v2.3 5/5] omap3isp: Quit using struct v4l2_subdev.host_priv field
Hi Sakari,
Thank you for the patch.
Quoted 57 lines · On Wednesday 16 Aug 2017 20:39:43 Sakari Ailus wrote:
struct v4l2_subdev.host_priv is intended to be used by another driver. This is hardly good design but back in the days of platform data was a quick hack to get things done.
As the sub-device specific bus information can be stored to the ISP driver specific struct allocated along with
v4l2_async_subdev, keep the information there and only there.Signed-off-by Sakari Ailus <[email protected]>---
since v2.2:- Introduce a macro
v4l2_subdev_to_bus_cfg()in order to remove non-trivial usage in places where conversion from sub-device to ISP bus configuration is needed.drivers/media/platform/omap3isp/isp.c | 29 ++++++-------------------- drivers/media/platform/omap3isp/isp.h | 4 +++- drivers/media/platform/omap3isp/ispccdc.c | 12 ++++++------ drivers/media/platform/omap3isp/ispccp2.c | 3 ++- drivers/media/platform/omap3isp/ispcsi2.c | 2 +- drivers/media/platform/omap3isp/ispcsiphy.c | 8 +++----- 6 files changed, 22 insertions(+), 36 deletions(-)(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/isp.cindex6cb1f0495804..c3014c82d64d100644drivers/media/platform/omap3isp/isp.c +0
-14@@ -2188,26 +2188,12 @@ static int isp_fwnodes_parse(struct device *dev,return -EINVAL ; } -static int isp_subdev_notifier_bound (struct v4l2_async_notifier *async, -struct v4l2_subdev *subdev, -struct v4l2_async_subdev *asd) -{ -struct isp_async_subdev *isd = - container_of(asd, struct isp_async_subdev, asd); - - isd->sd = subdev; - isd->sd->host_priv = &isd->bus; - -return 0 ; -} -static int isp_subdev_notifier_complete (struct v4l2_async_notifier *async) { struct isp_device *isp = container_of(async, struct isp_device, notifier);struct v4l2_device *v4l2_dev = &isp->v4l2_dev;struct v4l2_subdev *sd; -struct isp_bus_cfg *bus;int ret; ret =media_entity_enum_init (&isp->crashed, &isp->media_dev);
drivers/media/platform/omap3isp/isp.c static int isp_subdev_notifier_complete(struct · line 2218
Quoted 4 lines
drivers/media/platform/omap3isp/isp.c +0
-1@@ -2215,13 +2201,13 @@ static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async) return ret;list_for_each_entry (sd, &v4l2_dev->subdevs, list) { -/* Only try to link entities whose interface was set on bound
*/
Quoted 65 lines
drivers/media/platform/omap3isp/isp.c +7
-6-if (sd->host_priv) { - bus = (struct isp_bus_cfg *)sd->host_priv; - ret =isp_link_entity (isp, &sd->entity, bus- interface); -if (ret <0 ) -return ret; - } +if (!sd->asd) +continue ; + + ret =isp_link_entity (isp, &sd->entity, +v4l2_subdev_to_bus_cfg (sd)->interface); +if (ret <0 ) +return ret; }drivers/media/platform/omap3isp/isp.c +0
-1ret =v4l2_device_register_subdev_nodes (&isp->v4l2_dev);@@ -2399,7 +2385,6 @@ static int isp_probe(struct platform_device *pdev)if (ret <0 ) goto error_register_entities; - isp->notifier.bound = isp_subdev_notifier_bound; isp->notifier.complete = isp_subdev_notifier_complete; ret =v4l2_async_notifier_register (&isp->v4l2_dev, &isp->notifier);(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/isp.hindex2f2ae609c548..e528df6efc09100644drivers/media/platform/omap3isp/isp.h +3
-1@@ -226,11 +226,13 @@ struct isp_device { };struct isp_async_subdev { -struct v4l2_subdev *sd;struct isp_bus_cfg bus;struct v4l2_async_subdev asd; }; +#define v4l2_subdev_to_bus_cfg (sd) \ + (&container_of((sd)->asd, struct isp_async_subdev, asd)->bus) +#define v4l2_dev_to_isp_device (dev) \ container_of(dev, struct isp_device, v4l2_dev)(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispccdc.cindex4947876cfadf..80fed9526945100644drivers/media/platform/omap3isp/ispccdc.c +2
-1@@ -1139,7 +1139,8 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) pad = media_entity_remote_pad(&ccdc->pads[CCDC_PAD_SINK]); sensor =media_entity_to_v4l2_subdev (pad->entity);if (ccdc->input ==CCDC_INPUT_PARALLEL ) { - parcfg = &((struct isp_bus_cfg *)sensor->host_priv) + parcfg = &v4l2_subdev_to_bus_cfg ( +to_isp_pipeline (&ccdc->subdev.entity)->external) ->bus.parallel; ccdc->bt656 = parcfg->bt656; }@@ -2412,11 +2413,10 @@ static int ccdc_link_validate(struct v4l2_subdev *sd,/* We've got a parallel sensor here. */ if (ccdc->input == CCDC_INPUT_PARALLEL) {
drivers/media/platform/omap3isp/ispccdc.c static int ccdc_link_validate(struct v4l2_subdev · line 2421
Quoted 10 lines
drivers/media/platform/omap3isp/ispccdc.c +4
-5-struct isp_parallel_cfg *parcfg = - &((struct isp_bus_cfg *) -media_entity_to_v4l2_subdev (link->source->entity) - ->host_priv)->bus.parallel; - parallel_shift = parcfg->data_lane_shift; + parallel_shift = +v4l2_subdev_to_bus_cfg ( +to_isp_pipeline (&ccdc->subdev.entity)- external) + ->bus.parallel.data_lane_shift;
This oopses because pipe->external is NULL :-( pipe->external is set in isp_video_check_external_subdevs(), which is called after media_pipeline_start().
Quoted 46 lines
drivers/media/platform/omap3isp/ispccdc.c +0
-0}else {drivers/media/platform/omap3isp/ispccdc.c +0
-0parallel_shift =0 ; }(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispccp2.cindex3db8df09cd9a..e062939d0d05100644drivers/media/platform/omap3isp/ispccp2.c +2
-1@@ -350,6 +350,7 @@ static void ccp2_lcx_config(struct isp_ccp2_device*ccp2, */ static int ccp2_if_configure (struct isp_ccp2_device *ccp2) { +struct isp_pipeline *pipe =to_isp_pipeline (&ccp2->subdev.entity);const struct isp_bus_cfg *buscfg;struct v4l2_mbus_framefmt *format;struct media_pad *pad;@@ -361,7 +362,7 @@ static int ccp2_if_configure(struct isp_ccp2_device *ccp2) pad =media_entity_remote_pad (&ccp2->pads[CCP2_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity); - buscfg = sensor->host_priv; + buscfg =v4l2_subdev_to_bus_cfg (pipe->external); ret =ccp2_phyif_config (ccp2, &buscfg->bus.ccp2);drivers/media/platform/omap3isp/ispccp2.c +0
-0if (ret <0 )(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispcsi2.cindex3ec37fed710b..a4d3d030e81e100644drivers/media/platform/omap3isp/ispcsi2.c +1
-1@@ -566,7 +566,7 @@ static int csi2_configure(struct isp_csi2_device *csi2) pad =media_entity_remote_pad (&csi2->pads[CSI2_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity); - buscfg = sensor->host_priv; + buscfg =v4l2_subdev_to_bus_cfg (pipe->external); csi2->frame_skip =0 ;v4l2_subdev_call (sensor, sensor, g_skip_frames, &csi2->frame_skip);(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispcsiphy.cindexed1eb9907ae0..a28fb79abaac100644
drivers/media/platform/omap3isp/ispcsiphy.c static int csiphy_set_power(struct isp_csiphy *phy, u32 · line 169
Quoted 5 lines
drivers/media/platform/omap3isp/ispcsiphy.c +0
-2@@ -165,10 +165,7 @@ static int csiphy_set_power(struct isp_csiphy *phy, u32 power) static int omap3isp_csiphy_config(struct isp_csiphy *phy) {struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_async_subdev *isd = - container_of(pipe->external->asd, struct isp_async_subdev,
asd);
Quoted 16 lines
drivers/media/platform/omap3isp/ispcsiphy.c +3
-3-struct isp_bus_cfg *buscfg = pipe->external->host_priv ? - pipe->external->host_priv : &isd->bus; +struct isp_bus_cfg *buscfg =v4l2_subdev_to_bus_cfg (pipe->external);struct isp_csiphy_lanes_cfg *lanes;int csi2_ddrclk_khz;unsigned int num_data_lanes, used_lanes =0 ;@@ -311,7 +308,8 @@ void omap3isp_csiphy_release(struct isp_csiphy *phy)mutex_lock (&phy->mutex);if (phy->entity) {struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_bus_cfg *buscfg = pipe->external->host_priv; +struct isp_bus_cfg *buscfg = +v4l2_subdev_to_bus_cfg (pipe->external);csiphy_routing_cfg (phy, buscfg->interface, false, buscfg->bus.ccp2.phy_layer);
Signature · 3 lines
Regards, Laurent Pinchart
PATCH v2 5/5 omap3isp: Quit using struct v4l2_subdev.host_priv field
struct v4l2_subdev.host_priv is intended to be used by another driver. This is hardly good design but back in the days of platform data was a quick hack to get things done.
As the sub-device specific bus information can be stored to the ISP driver specific struct allocated along with v4l2_async_subdev, keep the information there and only there.
---
since v2.3:
- Fix obtaining the external entity in ispccdc.c.
drivers/media/platform/omap3isp/isp.c | 29 +++++++---------------------- drivers/media/platform/omap3isp/isp.h | 4 +++- drivers/media/platform/omap3isp/ispccdc.c | 12 ++++++------ drivers/media/platform/omap3isp/ispccp2.c | 3 ++- drivers/media/platform/omap3isp/ispcsi2.c | 2 +- drivers/media/platform/omap3isp/ispcsiphy.c | 8 +++----- 6 files changed, 22 insertions(+), 36 deletions(-)
drivers/media/platform/omap3isp/isp.c +7 -22
@@ -2188,26 +2188,12 @@ static int isp_fwnodes_parse(struct device *dev,return -EINVAL ; } -static int isp_subdev_notifier_bound (struct v4l2_async_notifier *async, -struct v4l2_subdev *subdev, -struct v4l2_async_subdev *asd) -{ -struct isp_async_subdev *isd = - container_of(asd, struct isp_async_subdev, asd); - - isd->sd = subdev; - isd->sd->host_priv = &isd->bus; - -return 0 ; -} -static int isp_subdev_notifier_complete (struct v4l2_async_notifier *async) { struct isp_device *isp = container_of(async, struct isp_device, notifier);struct v4l2_device *v4l2_dev = &isp->v4l2_dev;struct v4l2_subdev *sd; -struct isp_bus_cfg *bus;int ret; ret =media_entity_enum_init (&isp->crashed, &isp->media_dev);
@@ -2215,13 +2201,13 @@ static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async)return ret;list_for_each_entry (sd, &v4l2_dev->subdevs, list) { -/* Only try to link entities whose interface was set on bound */ -if (sd->host_priv) { - bus = (struct isp_bus_cfg *)sd->host_priv; - ret =isp_link_entity (isp, &sd->entity, bus->interface); -if (ret <0 ) -return ret; - } +if (!sd->asd) +continue ; + + ret =isp_link_entity (isp, &sd->entity, +v4l2_subdev_to_bus_cfg (sd)->interface); +if (ret <0 ) +return ret; } ret =v4l2_device_register_subdev_nodes (&isp->v4l2_dev);
@@ -2399,7 +2385,6 @@ static int isp_probe(struct platform_device *pdev)if (ret <0 ) goto error_register_entities; - isp->notifier.bound = isp_subdev_notifier_bound; isp->notifier.complete = isp_subdev_notifier_complete; ret =v4l2_async_notifier_register (&isp->v4l2_dev, &isp->notifier);
drivers/media/platform/omap3isp/isp.h +3 -1
@@ -226,11 +226,13 @@ struct isp_device { };struct isp_async_subdev { -struct v4l2_subdev *sd;struct isp_bus_cfg bus;struct v4l2_async_subdev asd; }; +#define v4l2_subdev_to_bus_cfg (sd) \ + (&container_of((sd)->asd, struct isp_async_subdev, asd)->bus) +#define v4l2_dev_to_isp_device (dev) \ container_of(dev, struct isp_device, v4l2_dev)
drivers/media/platform/omap3isp/ispccdc.c +6 -6
@@ -1139,7 +1139,8 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) pad =media_entity_remote_pad (&ccdc->pads[CCDC_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity);if (ccdc->input ==CCDC_INPUT_PARALLEL ) { - parcfg = &((struct isp_bus_cfg *)sensor->host_priv) + parcfg = &v4l2_subdev_to_bus_cfg ( +to_isp_pipeline (&ccdc->subdev.entity)->external) ->bus.parallel; ccdc->bt656 = parcfg->bt656; }
@@ -2412,11 +2413,10 @@ static int ccdc_link_validate(struct v4l2_subdev *sd,/* We've got a parallel sensor here. */ if (ccdc->input ==CCDC_INPUT_PARALLEL ) { -struct isp_parallel_cfg *parcfg = - &((struct isp_bus_cfg *) -media_entity_to_v4l2_subdev (link->source->entity) - ->host_priv)->bus.parallel; - parallel_shift = parcfg->data_lane_shift; + parallel_shift = +v4l2_subdev_to_bus_cfg (media_entity_to_v4l2_subdev ( + link->source->entity)) + ->bus.parallel.data_lane_shift; }else { parallel_shift =0 ; }
drivers/media/platform/omap3isp/ispccp2.c +2 -1
@@ -350,6 +350,7 @@ static void ccp2_lcx_config(struct isp_ccp2_device *ccp2,*/ static int ccp2_if_configure (struct isp_ccp2_device *ccp2) { +struct isp_pipeline *pipe =to_isp_pipeline (&ccp2->subdev.entity);const struct isp_bus_cfg *buscfg;struct v4l2_mbus_framefmt *format;struct media_pad *pad;
@@ -361,7 +362,7 @@ static int ccp2_if_configure(struct isp_ccp2_device *ccp2) pad =media_entity_remote_pad (&ccp2->pads[CCP2_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity); - buscfg = sensor->host_priv; + buscfg =v4l2_subdev_to_bus_cfg (pipe->external); ret =ccp2_phyif_config (ccp2, &buscfg->bus.ccp2);if (ret <0 )
drivers/media/platform/omap3isp/ispcsi2.c +1 -1
@@ -566,7 +566,7 @@ static int csi2_configure(struct isp_csi2_device *csi2) pad =media_entity_remote_pad (&csi2->pads[CSI2_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity); - buscfg = sensor->host_priv; + buscfg =v4l2_subdev_to_bus_cfg (pipe->external); csi2->frame_skip =0 ;v4l2_subdev_call (sensor, sensor, g_skip_frames, &csi2->frame_skip);
drivers/media/platform/omap3isp/ispcsiphy.c +3 -5
@@ -165,10 +165,7 @@ static int csiphy_set_power(struct isp_csiphy *phy, u32 power)static int omap3isp_csiphy_config (struct isp_csiphy *phy) {struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_async_subdev *isd = - container_of(pipe->external->asd, struct isp_async_subdev, asd); -struct isp_bus_cfg *buscfg = pipe->external->host_priv ? - pipe->external->host_priv : &isd->bus; +struct isp_bus_cfg *buscfg =v4l2_subdev_to_bus_cfg (pipe->external);struct isp_csiphy_lanes_cfg *lanes;int csi2_ddrclk_khz;unsigned int num_data_lanes, used_lanes =0 ;
@@ -311,7 +308,8 @@ void omap3isp_csiphy_release(struct isp_csiphy *phy)mutex_lock (&phy->mutex);if (phy->entity) {struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_bus_cfg *buscfg = pipe->external->host_priv; +struct isp_bus_cfg *buscfg = +v4l2_subdev_to_bus_cfg (pipe->external);csiphy_routing_cfg (phy, buscfg->interface, false, buscfg->bus.ccp2.phy_layer);
Signature · 1 line
2.11.0
PATCH v2 5/5 omap3isp: Quit using struct v4l2_subdev.host_priv field
struct v4l2_subdev.host_priv is intended to be used by another driver. This is hardly good design but back in the days of platform data was a quick hack to get things done.
As the sub-device specific bus information can be stored to the ISP driver specific struct allocated along with v4l2_async_subdev, keep the information there and only there.
---
since v2.4:
- Use temporary variables to avoid somewhat lengthy statements.
drivers/media/platform/omap3isp/isp.c | 29 +++++++---------------------- drivers/media/platform/omap3isp/isp.h | 4 +++- drivers/media/platform/omap3isp/ispccdc.c | 16 +++++++++------- drivers/media/platform/omap3isp/ispccp2.c | 3 ++- drivers/media/platform/omap3isp/ispcsi2.c | 2 +- drivers/media/platform/omap3isp/ispcsiphy.c | 8 +++----- 6 files changed, 25 insertions(+), 37 deletions(-)
drivers/media/platform/omap3isp/isp.c +7 -22
@@ -2188,26 +2188,12 @@ static int isp_fwnodes_parse(struct device *dev,return -EINVAL ; } -static int isp_subdev_notifier_bound (struct v4l2_async_notifier *async, -struct v4l2_subdev *subdev, -struct v4l2_async_subdev *asd) -{ -struct isp_async_subdev *isd = - container_of(asd, struct isp_async_subdev, asd); - - isd->sd = subdev; - isd->sd->host_priv = &isd->bus; - -return 0 ; -} -static int isp_subdev_notifier_complete (struct v4l2_async_notifier *async) { struct isp_device *isp = container_of(async, struct isp_device, notifier);struct v4l2_device *v4l2_dev = &isp->v4l2_dev;struct v4l2_subdev *sd; -struct isp_bus_cfg *bus;int ret; ret =media_entity_enum_init (&isp->crashed, &isp->media_dev);
@@ -2215,13 +2201,13 @@ static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async)return ret;list_for_each_entry (sd, &v4l2_dev->subdevs, list) { -/* Only try to link entities whose interface was set on bound */ -if (sd->host_priv) { - bus = (struct isp_bus_cfg *)sd->host_priv; - ret =isp_link_entity (isp, &sd->entity, bus->interface); -if (ret <0 ) -return ret; - } +if (!sd->asd) +continue ; + + ret =isp_link_entity (isp, &sd->entity, +v4l2_subdev_to_bus_cfg (sd)->interface); +if (ret <0 ) +return ret; } ret =v4l2_device_register_subdev_nodes (&isp->v4l2_dev);
@@ -2399,7 +2385,6 @@ static int isp_probe(struct platform_device *pdev)if (ret <0 ) goto error_register_entities; - isp->notifier.bound = isp_subdev_notifier_bound; isp->notifier.complete = isp_subdev_notifier_complete; ret =v4l2_async_notifier_register (&isp->v4l2_dev, &isp->notifier);
drivers/media/platform/omap3isp/isp.h +3 -1
@@ -226,11 +226,13 @@ struct isp_device { };struct isp_async_subdev { -struct v4l2_subdev *sd;struct isp_bus_cfg bus;struct v4l2_async_subdev asd; }; +#define v4l2_subdev_to_bus_cfg (sd) \ + (&container_of((sd)->asd, struct isp_async_subdev, asd)->bus) +#define v4l2_dev_to_isp_device (dev) \ container_of(dev, struct isp_device, v4l2_dev)
drivers/media/platform/omap3isp/ispccdc.c +9 -7
@@ -1139,8 +1139,10 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) pad =media_entity_remote_pad (&ccdc->pads[CCDC_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity);if (ccdc->input ==CCDC_INPUT_PARALLEL ) { - parcfg = &((struct isp_bus_cfg *)sensor->host_priv) - ->bus.parallel; +struct v4l2_subdev *sd = +to_isp_pipeline (&ccdc->subdev.entity)->external; + + parcfg = &v4l2_subdev_to_bus_cfg (sd)->bus.parallel; ccdc->bt656 = parcfg->bt656; }
@@ -2412,11 +2414,11 @@ static int ccdc_link_validate(struct v4l2_subdev *sd,/* We've got a parallel sensor here. */ if (ccdc->input ==CCDC_INPUT_PARALLEL ) { -struct isp_parallel_cfg *parcfg = - &((struct isp_bus_cfg *) -media_entity_to_v4l2_subdev (link->source->entity) - ->host_priv)->bus.parallel; - parallel_shift = parcfg->data_lane_shift; +struct v4l2_subdev *sd = +media_entity_to_v4l2_subdev (link->source->entity); +struct isp_bus_cfg *bus_cfg =v4l2_subdev_to_bus_cfg (sd); + + parallel_shift = bus_cfg->bus.parallel.data_lane_shift; }else { parallel_shift =0 ; }
drivers/media/platform/omap3isp/ispccp2.c +2 -1
@@ -350,6 +350,7 @@ static void ccp2_lcx_config(struct isp_ccp2_device *ccp2,*/ static int ccp2_if_configure (struct isp_ccp2_device *ccp2) { +struct isp_pipeline *pipe =to_isp_pipeline (&ccp2->subdev.entity);const struct isp_bus_cfg *buscfg;struct v4l2_mbus_framefmt *format;struct media_pad *pad;
@@ -361,7 +362,7 @@ static int ccp2_if_configure(struct isp_ccp2_device *ccp2) pad =media_entity_remote_pad (&ccp2->pads[CCP2_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity); - buscfg = sensor->host_priv; + buscfg =v4l2_subdev_to_bus_cfg (pipe->external); ret =ccp2_phyif_config (ccp2, &buscfg->bus.ccp2);if (ret <0 )
drivers/media/platform/omap3isp/ispcsi2.c +1 -1
@@ -566,7 +566,7 @@ static int csi2_configure(struct isp_csi2_device *csi2) pad =media_entity_remote_pad (&csi2->pads[CSI2_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity); - buscfg = sensor->host_priv; + buscfg =v4l2_subdev_to_bus_cfg (pipe->external); csi2->frame_skip =0 ;v4l2_subdev_call (sensor, sensor, g_skip_frames, &csi2->frame_skip);
drivers/media/platform/omap3isp/ispcsiphy.c +3 -5
@@ -165,10 +165,7 @@ static int csiphy_set_power(struct isp_csiphy *phy, u32 power)static int omap3isp_csiphy_config (struct isp_csiphy *phy) {struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_async_subdev *isd = - container_of(pipe->external->asd, struct isp_async_subdev, asd); -struct isp_bus_cfg *buscfg = pipe->external->host_priv ? - pipe->external->host_priv : &isd->bus; +struct isp_bus_cfg *buscfg =v4l2_subdev_to_bus_cfg (pipe->external);struct isp_csiphy_lanes_cfg *lanes;int csi2_ddrclk_khz;unsigned int num_data_lanes, used_lanes =0 ;
@@ -311,7 +308,8 @@ void omap3isp_csiphy_release(struct isp_csiphy *phy)mutex_lock (&phy->mutex);if (phy->entity) {struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_bus_cfg *buscfg = pipe->external->host_priv; +struct isp_bus_cfg *buscfg = +v4l2_subdev_to_bus_cfg (pipe->external);csiphy_routing_cfg (phy, buscfg->interface, false, buscfg->bus.ccp2.phy_layer);
Signature · 1 line
2.11.0
Re: [PATCH v2.5 5/5] omap3isp: Quit using struct v4l2_subdev.host_priv field
Hi Sakari,
Thank you for the patch.
Quoted 9 lines · On Thursday 17 Aug 2017 16:27:38 Sakari Ailus wrote:
struct v4l2_subdev.host_priv is intended to be used by another driver. This is hardly good design but back in the days of platform data was a quick hack to get things done.
As the sub-device specific bus information can be stored to the ISP driver specific struct allocated along with
v4l2_async_subdev, keep the information there and only there.Signed-off-by Sakari Ailus <[email protected]>
Quoted 46 lines
---
since v2.4:- Use temporary variables to avoid somewhat lengthy statements.
drivers/media/platform/omap3isp/isp.c | 29 ++++++-------------------- drivers/media/platform/omap3isp/isp.h | 4 +++- drivers/media/platform/omap3isp/ispccdc.c | 16 +++++++++------- drivers/media/platform/omap3isp/ispccp2.c | 3 ++- drivers/media/platform/omap3isp/ispcsi2.c | 2 +- drivers/media/platform/omap3isp/ispcsiphy.c | 8 +++----- 6 files changed, 25 insertions(+), 37 deletions(-)(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/isp.cindex6cb1f0495804..c3014c82d64d100644drivers/media/platform/omap3isp/isp.c +0
-14@@ -2188,26 +2188,12 @@ static int isp_fwnodes_parse(struct device *dev,return -EINVAL ; } -static int isp_subdev_notifier_bound (struct v4l2_async_notifier *async, -struct v4l2_subdev *subdev, -struct v4l2_async_subdev *asd) -{ -struct isp_async_subdev *isd = - container_of(asd, struct isp_async_subdev, asd); - - isd->sd = subdev; - isd->sd->host_priv = &isd->bus; - -return 0 ; -} -static int isp_subdev_notifier_complete (struct v4l2_async_notifier *async) { struct isp_device *isp = container_of(async, struct isp_device, notifier);struct v4l2_device *v4l2_dev = &isp->v4l2_dev;struct v4l2_subdev *sd; -struct isp_bus_cfg *bus;int ret; ret =media_entity_enum_init (&isp->crashed, &isp->media_dev);
drivers/media/platform/omap3isp/isp.c static int isp_subdev_notifier_complete(struct · line 2218
Quoted 4 lines
drivers/media/platform/omap3isp/isp.c +0
-1@@ -2215,13 +2201,13 @@ static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async) return ret;list_for_each_entry (sd, &v4l2_dev->subdevs, list) { -/* Only try to link entities whose interface was set on bound
*/
Quoted 124 lines
drivers/media/platform/omap3isp/isp.c +7
-6-if (sd->host_priv) { - bus = (struct isp_bus_cfg *)sd->host_priv; - ret =isp_link_entity (isp, &sd->entity, bus- interface); -if (ret <0 ) -return ret; - } +if (!sd->asd) +continue ; + + ret =isp_link_entity (isp, &sd->entity, +v4l2_subdev_to_bus_cfg (sd)->interface); +if (ret <0 ) +return ret; }drivers/media/platform/omap3isp/isp.c +0
-1ret =v4l2_device_register_subdev_nodes (&isp->v4l2_dev);@@ -2399,7 +2385,6 @@ static int isp_probe(struct platform_device *pdev)if (ret <0 ) goto error_register_entities; - isp->notifier.bound = isp_subdev_notifier_bound; isp->notifier.complete = isp_subdev_notifier_complete; ret =v4l2_async_notifier_register (&isp->v4l2_dev, &isp->notifier);(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/isp.hindex2f2ae609c548..e528df6efc09100644drivers/media/platform/omap3isp/isp.h +3
-1@@ -226,11 +226,13 @@ struct isp_device { };struct isp_async_subdev { -struct v4l2_subdev *sd;struct isp_bus_cfg bus;struct v4l2_async_subdev asd; }; +#define v4l2_subdev_to_bus_cfg (sd) \ + (&container_of((sd)->asd, struct isp_async_subdev, asd)->bus) +#define v4l2_dev_to_isp_device (dev) \ container_of(dev, struct isp_device, v4l2_dev)(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispccdc.cindex4947876cfadf..b66276ab5765100644drivers/media/platform/omap3isp/ispccdc.c +9
-7@@ -1139,8 +1139,10 @@ static void ccdc_configure(struct isp_ccdc_device *ccdc) pad = media_entity_remote_pad(&ccdc->pads[CCDC_PAD_SINK]); sensor =media_entity_to_v4l2_subdev (pad->entity);if (ccdc->input ==CCDC_INPUT_PARALLEL ) { - parcfg = &((struct isp_bus_cfg *)sensor->host_priv) - ->bus.parallel; +struct v4l2_subdev *sd = +to_isp_pipeline (&ccdc->subdev.entity)->external; + + parcfg = &v4l2_subdev_to_bus_cfg (sd)->bus.parallel; ccdc->bt656 = parcfg->bt656; }@@ -2412,11 +2414,11 @@ static int ccdc_link_validate(struct v4l2_subdev *sd,/* We've got a parallel sensor here. */ if (ccdc->input ==CCDC_INPUT_PARALLEL ) { -struct isp_parallel_cfg *parcfg = - &((struct isp_bus_cfg *) -media_entity_to_v4l2_subdev (link->source->entity) - ->host_priv)->bus.parallel; - parallel_shift = parcfg->data_lane_shift; +struct v4l2_subdev *sd = +media_entity_to_v4l2_subdev (link->source->entity); +struct isp_bus_cfg *bus_cfg =v4l2_subdev_to_bus_cfg (sd); + + parallel_shift = bus_cfg->bus.parallel.data_lane_shift; }else { parallel_shift =0 ;drivers/media/platform/omap3isp/ispccdc.c +0
-0}(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispccp2.cindex3db8df09cd9a..e062939d0d05100644drivers/media/platform/omap3isp/ispccp2.c +2
-1@@ -350,6 +350,7 @@ static void ccp2_lcx_config(struct isp_ccp2_device*ccp2, */ static int ccp2_if_configure (struct isp_ccp2_device *ccp2) { +struct isp_pipeline *pipe =to_isp_pipeline (&ccp2->subdev.entity);const struct isp_bus_cfg *buscfg;struct v4l2_mbus_framefmt *format;struct media_pad *pad;@@ -361,7 +362,7 @@ static int ccp2_if_configure(struct isp_ccp2_device *ccp2) pad =media_entity_remote_pad (&ccp2->pads[CCP2_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity); - buscfg = sensor->host_priv; + buscfg =v4l2_subdev_to_bus_cfg (pipe->external); ret =ccp2_phyif_config (ccp2, &buscfg->bus.ccp2);drivers/media/platform/omap3isp/ispccp2.c +0
-0if (ret <0 )(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispcsi2.cindex3ec37fed710b..a4d3d030e81e100644drivers/media/platform/omap3isp/ispcsi2.c +1
-1@@ -566,7 +566,7 @@ static int csi2_configure(struct isp_csi2_device *csi2) pad =media_entity_remote_pad (&csi2->pads[CSI2_PAD_SINK ]); sensor =media_entity_to_v4l2_subdev (pad->entity); - buscfg = sensor->host_priv; + buscfg =v4l2_subdev_to_bus_cfg (pipe->external); csi2->frame_skip =0 ;v4l2_subdev_call (sensor, sensor, g_skip_frames, &csi2->frame_skip);(quoted diff) +0
-0
b/drivers/media/platform/omap3isp/ispcsiphy.cindexed1eb9907ae0..a28fb79abaac100644
drivers/media/platform/omap3isp/ispcsiphy.c static int csiphy_set_power(struct isp_csiphy *phy, u32 · line 169
Quoted 5 lines
drivers/media/platform/omap3isp/ispcsiphy.c +0
-2@@ -165,10 +165,7 @@ static int csiphy_set_power(struct isp_csiphy *phy, u32 power) static int omap3isp_csiphy_config(struct isp_csiphy *phy) {struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_async_subdev *isd = - container_of(pipe->external->asd, struct isp_async_subdev,
asd);
Quoted 16 lines
drivers/media/platform/omap3isp/ispcsiphy.c +3
-3-struct isp_bus_cfg *buscfg = pipe->external->host_priv ? - pipe->external->host_priv : &isd->bus; +struct isp_bus_cfg *buscfg =v4l2_subdev_to_bus_cfg (pipe->external);struct isp_csiphy_lanes_cfg *lanes;int csi2_ddrclk_khz;unsigned int num_data_lanes, used_lanes =0 ;@@ -311,7 +308,8 @@ void omap3isp_csiphy_release(struct isp_csiphy *phy)mutex_lock (&phy->mutex);if (phy->entity) {struct isp_pipeline *pipe =to_isp_pipeline (phy->entity); -struct isp_bus_cfg *buscfg = pipe->external->host_priv; +struct isp_bus_cfg *buscfg = +v4l2_subdev_to_bus_cfg (pipe->external);csiphy_routing_cfg (phy, buscfg->interface, false, buscfg->bus.ccp2.phy_layer);
Signature · 3 lines
Regards, Laurent Pinchart