Linux Media Controller development
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Kieran Bingham <kieran.bingham@ideasonboard.com>
Cc: linux-media@vger.kernel.org,
	Tomi Valkeinen <tomi.valkeinen@ti.com>,
	Benoit Parrot <bparrot@ti.com>
Subject: Re: [PATCH v1 036/107] media: ti-vpe: cal: Reorganize remaining code in sections
Date: Wed, 17 Jun 2020 14:04:59 +0300	[thread overview]
Message-ID: <20200617110459.GD5838@pendragon.ideasonboard.com> (raw)
In-Reply-To: <fb2fadf7-3742-274f-5de9-0771631b08de@ideasonboard.com>

Hi Kieran,

On Wed, Jun 17, 2020 at 12:01:39PM +0100, Kieran Bingham wrote:
> On 17/06/2020 11:54, Kieran Bingham wrote:
> > On 17/06/2020 11:51, Laurent Pinchart wrote:
> >> On Wed, Jun 17, 2020 at 11:00:31AM +0100, Kieran Bingham wrote:
> >>> On 15/06/2020 00:58, Laurent Pinchart wrote:
> >>>> Increase readability by reorganizing the remaining code in sections. No
> >>>> functional change is included.
> >>>>
> >>>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >>>> ---
> >>>>  drivers/media/platform/ti-vpe/cal.c | 350 +++++++++++++++-------------
> >>>>  1 file changed, 187 insertions(+), 163 deletions(-)
> >>>>
> >>>> diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
> >>>> index 176f616033a1..6f33853ecdb2 100644
> >>>> --- a/drivers/media/platform/ti-vpe/cal.c
> >>>> +++ b/drivers/media/platform/ti-vpe/cal.c
> >>>> @@ -37,9 +37,6 @@
> >>>>  
> >>>>  #define CAL_MODULE_NAME "cal"
> >>>>  
> >>>> -#define MAX_WIDTH_BYTES (8192 * 8)
> >>>> -#define MAX_HEIGHT_LINES 16383
> >>>> -
> >>>>  MODULE_DESCRIPTION("TI CAL driver");
> >>>>  MODULE_AUTHOR("Benoit Parrot, <bparrot@ti.com>");
> >>>>  MODULE_LICENSE("GPL v2");
> >>>> @@ -79,11 +76,11 @@ MODULE_PARM_DESC(debug, "activates debug info");
> >>>>  
> >>>>  #define CAL_NUM_CONTEXT 2
> >>>>  
> >>>> -#define reg_read(dev, offset) ioread32(dev->base + offset)
> >>>> -#define reg_write(dev, offset, val) iowrite32(val, dev->base + offset)
> >>>> +#define MAX_WIDTH_BYTES (8192 * 8)
> >>>> +#define MAX_HEIGHT_LINES 16383
> >>>>  
> >>>>  /* ------------------------------------------------------------------
> >>>> - *	Basic structures
> >>>> + *	Format Handling
> >>>>   * ------------------------------------------------------------------
> >>>>   */
> >>>>  
> >>>> @@ -204,6 +201,11 @@ static char *fourcc_to_str(u32 fmt)
> >>>>  	return code;
> >>>>  }
> >>>>  
> >>>> +/* ------------------------------------------------------------------
> >>>> + *	Driver Structures
> >>>> + * ------------------------------------------------------------------
> >>>> + */
> >>>> +
> >>>>  /* buffer for one video frame */
> >>>>  struct cal_buffer {
> >>>>  	/* common v4l buffer stuff -- must be first */
> >>>> @@ -239,80 +241,6 @@ struct cal_data {
> >>>>  	unsigned int flags;
> >>>>  };
> >>>>  
> >>>> -static const struct cal_camerarx_data dra72x_cal_camerarx[] = {
> >>>> -	{
> >>>> -		.fields = {
> >>>> -			[F_CTRLCLKEN] = { 10, 10 },
> >>>> -			[F_CAMMODE] = { 11, 12 },
> >>>> -			[F_LANEENABLE] = { 13, 16 },
> >>>> -			[F_CSI_MODE] = { 17, 17 },
> >>>> -		},
> >>>> -		.num_lanes = 4,
> >>>> -	},
> >>>> -	{
> >>>> -		.fields = {
> >>>> -			[F_CTRLCLKEN] = { 0, 0 },
> >>>> -			[F_CAMMODE] = { 1, 2 },
> >>>> -			[F_LANEENABLE] = { 3, 4 },
> >>>> -			[F_CSI_MODE] = { 5, 5 },
> >>>> -		},
> >>>> -		.num_lanes = 2,
> >>>> -	},
> >>>> -};
> >>>> -
> >>>> -static const struct cal_data dra72x_cal_data = {
> >>>> -	.camerarx = dra72x_cal_camerarx,
> >>>> -	.num_csi2_phy = ARRAY_SIZE(dra72x_cal_camerarx),
> >>>> -};
> >>>> -
> >>>> -static const struct cal_data dra72x_es1_cal_data = {
> >>>> -	.camerarx = dra72x_cal_camerarx,
> >>>> -	.num_csi2_phy = ARRAY_SIZE(dra72x_cal_camerarx),
> >>>> -	.flags = DRA72_CAL_PRE_ES2_LDO_DISABLE,
> >>>> -};
> >>>> -
> >>>> -static const struct cal_camerarx_data dra76x_cal_csi_phy[] = {
> >>>> -	{
> >>>> -		.fields = {
> >>>> -			[F_CTRLCLKEN] = { 8, 8 },
> >>>> -			[F_CAMMODE] = { 9, 10 },
> >>>> -			[F_CSI_MODE] = { 11, 11 },
> >>>> -			[F_LANEENABLE] = { 27, 31 },
> >>>> -		},
> >>>> -		.num_lanes = 5,
> >>>> -	},
> >>>> -	{
> >>>> -		.fields = {
> >>>> -			[F_CTRLCLKEN] = { 0, 0 },
> >>>> -			[F_CAMMODE] = { 1, 2 },
> >>>> -			[F_CSI_MODE] = { 3, 3 },
> >>>> -			[F_LANEENABLE] = { 24, 26 },
> >>>> -		},
> >>>> -		.num_lanes = 3,
> >>>> -	},
> >>>> -};
> >>>> -
> >>>> -static const struct cal_data dra76x_cal_data = {
> >>>> -	.camerarx = dra76x_cal_csi_phy,
> >>>> -	.num_csi2_phy = ARRAY_SIZE(dra76x_cal_csi_phy),
> >>>> -};
> >>>> -
> >>>> -static const struct cal_camerarx_data am654_cal_csi_phy[] = {
> >>>> -	{
> >>>> -		.fields = {
> >>>> -			[F_CTRLCLKEN] = { 15, 15 },
> >>>> -			[F_CAMMODE] = { 24, 25 },
> >>>> -			[F_LANEENABLE] = { 0, 4 },
> >>>> -		},
> >>>> -		.num_lanes = 5,
> >>>> -	},
> >>>> -};
> >>>> -
> >>>> -static const struct cal_data am654_cal_data = {
> >>>> -	.camerarx = am654_cal_csi_phy,
> >>>> -	.num_csi2_phy = ARRAY_SIZE(am654_cal_csi_phy),
> >>>> -};
> >>>> -
> >>>>  /*
> >>>>   * The Camera Adaptation Layer (CAL) module is paired with one or more complex
> >>>>   * I/O PHYs (CAMERARX). It contains multiple instances of CSI-2, processing and
> >>>> @@ -408,6 +336,98 @@ struct cal_ctx {
> >>>>  	bool dma_act;
> >>>>  };
> >>>>  
> >>>> +static inline struct cal_ctx *notifier_to_ctx(struct v4l2_async_notifier *n)
> >>>> +{
> >>>> +	return container_of(n, struct cal_ctx, notifier);
> >>>> +}
> >>>> +
> >>>> +/* ------------------------------------------------------------------
> >>>> + *	Platform Data
> >>>> + * ------------------------------------------------------------------
> >>>> + */
> >>>> +
> >>>> +static const struct cal_camerarx_data dra72x_cal_camerarx[] = {
> >>>> +	{
> >>>> +		.fields = {
> >>>> +			[F_CTRLCLKEN] = { 10, 10 },
> >>>> +			[F_CAMMODE] = { 11, 12 },
> >>>> +			[F_LANEENABLE] = { 13, 16 },
> >>>> +			[F_CSI_MODE] = { 17, 17 },
> >>>> +		},
> >>>> +		.num_lanes = 4,
> >>>> +	},
> >>>> +	{
> >>>> +		.fields = {
> >>>> +			[F_CTRLCLKEN] = { 0, 0 },
> >>>> +			[F_CAMMODE] = { 1, 2 },
> >>>> +			[F_LANEENABLE] = { 3, 4 },
> >>>> +			[F_CSI_MODE] = { 5, 5 },
> >>>> +		},
> >>>> +		.num_lanes = 2,
> >>>> +	},
> >>>> +};
> >>>> +
> >>>> +static const struct cal_data dra72x_cal_data = {
> >>>> +	.camerarx = dra72x_cal_camerarx,
> >>>> +	.num_csi2_phy = ARRAY_SIZE(dra72x_cal_camerarx),
> >>>> +};
> >>>> +
> >>>> +static const struct cal_data dra72x_es1_cal_data = {
> >>>> +	.camerarx = dra72x_cal_camerarx,
> >>>> +	.num_csi2_phy = ARRAY_SIZE(dra72x_cal_camerarx),
> >>>> +	.flags = DRA72_CAL_PRE_ES2_LDO_DISABLE,
> >>>> +};
> >>>> +
> >>>> +static const struct cal_camerarx_data dra76x_cal_csi_phy[] = {
> >>>> +	{
> >>>> +		.fields = {
> >>>> +			[F_CTRLCLKEN] = { 8, 8 },
> >>>> +			[F_CAMMODE] = { 9, 10 },
> >>>> +			[F_CSI_MODE] = { 11, 11 },
> >>>> +			[F_LANEENABLE] = { 27, 31 },
> >>>> +		},
> >>>> +		.num_lanes = 5,
> >>>> +	},
> >>>> +	{
> >>>> +		.fields = {
> >>>> +			[F_CTRLCLKEN] = { 0, 0 },
> >>>> +			[F_CAMMODE] = { 1, 2 },
> >>>> +			[F_CSI_MODE] = { 3, 3 },
> >>>> +			[F_LANEENABLE] = { 24, 26 },
> >>>> +		},
> >>>> +		.num_lanes = 3,
> >>>> +	},
> >>>> +};
> >>>> +
> >>>> +static const struct cal_data dra76x_cal_data = {
> >>>> +	.camerarx = dra76x_cal_csi_phy,
> >>>> +	.num_csi2_phy = ARRAY_SIZE(dra76x_cal_csi_phy),
> >>>> +};
> >>>> +
> >>>> +static const struct cal_camerarx_data am654_cal_csi_phy[] = {
> >>>> +	{
> >>>> +		.fields = {
> >>>> +			[F_CTRLCLKEN] = { 15, 15 },
> >>>> +			[F_CAMMODE] = { 24, 25 },
> >>>> +			[F_LANEENABLE] = { 0, 4 },
> >>>> +		},
> >>>> +		.num_lanes = 5,
> >>>> +	},
> >>>> +};
> >>>> +
> >>>> +static const struct cal_data am654_cal_data = {
> >>>> +	.camerarx = am654_cal_csi_phy,
> >>>> +	.num_csi2_phy = ARRAY_SIZE(am654_cal_csi_phy),
> >>>> +};
> >>>> +
> >>>> +/* ------------------------------------------------------------------
> >>>> + *	I/O Register Accessors
> >>>> + * ------------------------------------------------------------------
> >>>> + */
> >>>> +
> >>>> +#define reg_read(dev, offset) ioread32(dev->base + offset)
> >>>> +#define reg_write(dev, offset, val) iowrite32(val, dev->base + offset)
> >>>> +
> >>>>  static inline u32 reg_read_field(struct cal_dev *cal, u32 offset, u32 mask)
> >>>>  {
> >>>>  	return FIELD_GET(mask, reg_read(cal, offset));
> >>>> @@ -423,41 +443,6 @@ static inline void reg_write_field(struct cal_dev *cal, u32 offset, u32 value,
> >>>>  	reg_write(cal, offset, val);
> >>>>  }
> >>>>  
> >>>> -static const struct cal_fmt *find_format_by_pix(struct cal_ctx *ctx,
> >>>> -						u32 pixelformat)
> >>>> -{
> >>>> -	const struct cal_fmt *fmt;
> >>>> -	unsigned int k;
> >>>> -
> >>>> -	for (k = 0; k < ctx->num_active_fmt; k++) {
> >>>> -		fmt = ctx->active_fmt[k];
> >>>> -		if (fmt->fourcc == pixelformat)
> >>>> -			return fmt;
> >>>> -	}
> >>>> -
> >>>> -	return NULL;
> >>>> -}
> >>>> -
> >>>> -static const struct cal_fmt *find_format_by_code(struct cal_ctx *ctx,
> >>>> -						 u32 code)
> >>>> -{
> >>>> -	const struct cal_fmt *fmt;
> >>>> -	unsigned int k;
> >>>> -
> >>>> -	for (k = 0; k < ctx->num_active_fmt; k++) {
> >>>> -		fmt = ctx->active_fmt[k];
> >>>> -		if (fmt->code == code)
> >>>> -			return fmt;
> >>>> -	}
> >>>> -
> >>>> -	return NULL;
> >>>> -}
> >>>> -
> >>>> -static inline struct cal_ctx *notifier_to_ctx(struct v4l2_async_notifier *n)
> >>>> -{
> >>>> -	return container_of(n, struct cal_ctx, notifier);
> >>>> -}
> >>>> -
> >>>>  static inline void set_field(u32 *valp, u32 field, u32 mask)
> >>>>  {
> >>>>  	u32 val = *valp;
> >>>> @@ -493,11 +478,6 @@ static void cal_quickdump_regs(struct cal_dev *cal)
> >>>>  	}
> >>>>  }
> >>>>  
> >>>> -static u32 cal_data_get_num_csi2_phy(struct cal_dev *cal)
> >>>> -{
> >>>> -	return cal->data->num_csi2_phy;
> >>>> -}
> >>>> -
> >>>>  /* ------------------------------------------------------------------
> >>>>   *	CAMERARX Management
> >>>>   * ------------------------------------------------------------------
> >>>> @@ -1152,6 +1132,11 @@ static void cal_ctx_wr_dma_addr(struct cal_ctx *ctx, unsigned int dmaaddr)
> >>>>  	reg_write(ctx->cal, CAL_WR_DMA_ADDR(ctx->csi2_port), dmaaddr);
> >>>>  }
> >>>>  
> >>>> +/* ------------------------------------------------------------------
> >>>> + *	IRQ Handling
> >>>> + * ------------------------------------------------------------------
> >>>> + */
> >>>> +
> >>>>  static inline void cal_schedule_next_buffer(struct cal_ctx *ctx)
> >>>>  {
> >>>>  	struct cal_dmaqueue *dma_q = &ctx->vidq;
> >>>> @@ -1255,9 +1240,41 @@ static irqreturn_t cal_irq(int irq_cal, void *data)
> >>>>  	return IRQ_HANDLED;
> >>>>  }
> >>>>  
> >>>> -/*
> >>>> - * video ioctls
> >>>> +/* ------------------------------------------------------------------
> >>>> + *	V4L2 Video IOCTLs
> >>>> + * ------------------------------------------------------------------
> >>>>   */
> >>>> +
> >>>> +static const struct cal_fmt *find_format_by_pix(struct cal_ctx *ctx,
> >>>> +						u32 pixelformat)
> >>>> +{
> >>>> +	const struct cal_fmt *fmt;
> >>>> +	unsigned int k;
> >>>> +
> >>>> +	for (k = 0; k < ctx->num_active_fmt; k++) {
> >>>> +		fmt = ctx->active_fmt[k];
> >>>> +		if (fmt->fourcc == pixelformat)
> >>>> +			return fmt;
> >>>> +	}
> >>>> +
> >>>> +	return NULL;
> >>>> +}
> >>>> +
> >>>> +static const struct cal_fmt *find_format_by_code(struct cal_ctx *ctx,
> >>>> +						 u32 code)
> >>>> +{
> >>>> +	const struct cal_fmt *fmt;
> >>>> +	unsigned int k;
> >>>> +
> >>>> +	for (k = 0; k < ctx->num_active_fmt; k++) {
> >>>> +		fmt = ctx->active_fmt[k];
> >>>> +		if (fmt->code == code)
> >>>> +			return fmt;
> >>>> +	}
> >>>> +
> >>>> +	return NULL;
> >>>> +}
> >>>> +
> >>>>  static int cal_querycap(struct file *file, void *priv,
> >>>>  			struct v4l2_capability *cap)
> >>>>  {
> >>>> @@ -1566,9 +1583,46 @@ static int cal_enum_frameintervals(struct file *file, void *priv,
> >>>>  	return 0;
> >>>>  }
> >>>>  
> >>>> -/*
> >>>> - * Videobuf operations
> >>>> +static const struct v4l2_file_operations cal_fops = {
> >>>> +	.owner		= THIS_MODULE,
> >>>> +	.open           = v4l2_fh_open,
> >>>> +	.release        = vb2_fop_release,
> >>>> +	.read           = vb2_fop_read,
> >>>> +	.poll		= vb2_fop_poll,
> >>>> +	.unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */
> >>>> +	.mmap           = vb2_fop_mmap,
> >>>> +};
> >>>> +
> >>>> +static const struct v4l2_ioctl_ops cal_ioctl_ops = {
> >>>> +	.vidioc_querycap      = cal_querycap,
> >>>> +	.vidioc_enum_fmt_vid_cap  = cal_enum_fmt_vid_cap,
> >>>> +	.vidioc_g_fmt_vid_cap     = cal_g_fmt_vid_cap,
> >>>> +	.vidioc_try_fmt_vid_cap   = cal_try_fmt_vid_cap,
> >>>> +	.vidioc_s_fmt_vid_cap     = cal_s_fmt_vid_cap,
> >>>> +	.vidioc_enum_framesizes   = cal_enum_framesizes,
> >>>> +	.vidioc_reqbufs       = vb2_ioctl_reqbufs,
> >>>> +	.vidioc_create_bufs   = vb2_ioctl_create_bufs,
> >>>> +	.vidioc_prepare_buf   = vb2_ioctl_prepare_buf,
> >>>> +	.vidioc_querybuf      = vb2_ioctl_querybuf,
> >>>> +	.vidioc_qbuf          = vb2_ioctl_qbuf,
> >>>> +	.vidioc_dqbuf         = vb2_ioctl_dqbuf,
> >>>> +	.vidioc_expbuf        = vb2_ioctl_expbuf,
> >>>> +	.vidioc_enum_input    = cal_enum_input,
> >>>> +	.vidioc_g_input       = cal_g_input,
> >>>> +	.vidioc_s_input       = cal_s_input,
> >>>> +	.vidioc_enum_frameintervals = cal_enum_frameintervals,
> >>>> +	.vidioc_streamon      = vb2_ioctl_streamon,
> >>>> +	.vidioc_streamoff     = vb2_ioctl_streamoff,
> >>>> +	.vidioc_log_status    = v4l2_ctrl_log_status,
> >>>> +	.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
> >>>> +	.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
> >>>> +};
> >>>> +
> >>>> +/* ------------------------------------------------------------------
> >>>> + *	videobuf2 Operations
> >>>> + * ------------------------------------------------------------------
> >>>>   */
> >>>> +
> >>>>  static int cal_queue_setup(struct vb2_queue *vq,
> >>>>  			   unsigned int *nbuffers, unsigned int *nplanes,
> >>>>  			   unsigned int sizes[], struct device *alloc_devs[])
> >>>> @@ -1772,40 +1826,10 @@ static const struct vb2_ops cal_video_qops = {
> >>>>  	.wait_finish		= vb2_ops_wait_finish,
> >>>>  };
> >>>>  
> >>>> -static const struct v4l2_file_operations cal_fops = {
> >>>> -	.owner		= THIS_MODULE,
> >>>> -	.open           = v4l2_fh_open,
> >>>> -	.release        = vb2_fop_release,
> >>>> -	.read           = vb2_fop_read,
> >>>> -	.poll		= vb2_fop_poll,
> >>>> -	.unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */
> >>>> -	.mmap           = vb2_fop_mmap,
> >>>> -};
> >>>> -
> >>>> -static const struct v4l2_ioctl_ops cal_ioctl_ops = {
> >>>> -	.vidioc_querycap      = cal_querycap,
> >>>> -	.vidioc_enum_fmt_vid_cap  = cal_enum_fmt_vid_cap,
> >>>> -	.vidioc_g_fmt_vid_cap     = cal_g_fmt_vid_cap,
> >>>> -	.vidioc_try_fmt_vid_cap   = cal_try_fmt_vid_cap,
> >>>> -	.vidioc_s_fmt_vid_cap     = cal_s_fmt_vid_cap,
> >>>> -	.vidioc_enum_framesizes   = cal_enum_framesizes,
> >>>> -	.vidioc_reqbufs       = vb2_ioctl_reqbufs,
> >>>> -	.vidioc_create_bufs   = vb2_ioctl_create_bufs,
> >>>> -	.vidioc_prepare_buf   = vb2_ioctl_prepare_buf,
> >>>> -	.vidioc_querybuf      = vb2_ioctl_querybuf,
> >>>> -	.vidioc_qbuf          = vb2_ioctl_qbuf,
> >>>> -	.vidioc_dqbuf         = vb2_ioctl_dqbuf,
> >>>> -	.vidioc_expbuf        = vb2_ioctl_expbuf,
> >>>> -	.vidioc_enum_input    = cal_enum_input,
> >>>> -	.vidioc_g_input       = cal_g_input,
> >>>> -	.vidioc_s_input       = cal_s_input,
> >>>> -	.vidioc_enum_frameintervals = cal_enum_frameintervals,
> >>>> -	.vidioc_streamon      = vb2_ioctl_streamon,
> >>>> -	.vidioc_streamoff     = vb2_ioctl_streamoff,
> >>>> -	.vidioc_log_status    = v4l2_ctrl_log_status,
> >>>> -	.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
> >>>> -	.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
> >>>> -};
> >>>> +/* ------------------------------------------------------------------
> >>>> + *	Initialization and module stuff
> >>>> + * ------------------------------------------------------------------
> >>>> + */
> >>>>  
> >>>>  static const struct video_device cal_videodev = {
> >>>>  	.name		= CAL_MODULE_NAME,
> >>>> @@ -1817,11 +1841,6 @@ static const struct video_device cal_videodev = {
> >>>>  			  V4L2_CAP_READWRITE,
> >>>>  };
> >>>>  
> >>>> -/* -----------------------------------------------------------------
> >>>> - *	Initialization and module stuff
> >>>> - * ------------------------------------------------------------------
> >>>> - */
> >>>> -
> >>>>  static int cal_complete_ctx(struct cal_ctx *ctx)
> >>>>  {
> >>>>  	struct video_device *vfd;
> >>>> @@ -2242,6 +2261,11 @@ static void cal_get_hwinfo(struct cal_dev *cal)
> >>>>  		hwinfo);
> >>>>  }
> >>>>  
> >>>
> >>>
> >>> Overall, the reorganisation is certainly helpful.
> >>>
> >>>> +static u32 cal_data_get_num_csi2_phy(struct cal_dev *cal)
> >>>> +{
> >>>> +	return cal->data->num_csi2_phy;
> >>>> +}
> >>>
> >>> However, this function (which is possibly a bit overkill on it's own
> >>> anyway) could be moved much higher in the module, so that /all/
> >>> references to the num_csi2_phy variable are accessed through it.
> >>>
> >>> Otherwise, the code is inconsistent with other parts of the driver
> >>> directly accessing this value even with an accessor.
> >>>
> >>> We could remove the accessor... or - apply the patch "media: ti-vpe:
> >>> cal: Use cal_data_get_num_csi2_phy() consistently" (which will follow
> >>> next) on top.
> >>
> >> I think I'd rather remove the accessors, this function provides little
> >> value.
> > 
> > It had some value in giving me a clean place to override having only a
> > single phy, but that's not a reason to keep it (just helpful while
> > debugging).
> > 
> > I'm fine dropping the accessor, and open-coding the usage too.
> 
> Actually, further to that - we might want some loop helper here on this
> topic anyway, as when a PHY is unused (/unconnected) we need a good way
> to make sure we don't process anything on that phy.
> 
> I think all of the places where that accessor is used would be key
> locations that should also check if the phy is defined too.
> 
> But that accessor alone is not enough, there needs to be a check that
> the phy was created too. (currently working through that now for better
> support on the DRA76-evm which has two phys, and only one is connected
> to the OV5640).

Shouldn't we still create two cal_camerarx instances, even if only one
of them is used ? Think about it from a media controller point of view,
there should be two phy entities, even if one has its input left
unconnected.

> >>> Otherwise,
> >>>
> >>> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> >>>
> >>>> +
> >>>>  static int cal_probe(struct platform_device *pdev)
> >>>>  {
> >>>>  	struct cal_dev *cal;

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2020-06-17 11:05 UTC|newest]

Thread overview: 149+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-14 23:57 [PATCH v1 000/107] media: ti-vpe: cal: Add media controller support Laurent Pinchart
2020-06-14 23:57 ` [PATCH v1 001/107] media: ti-vpe: cal: Sort headers alphabetically Laurent Pinchart
2020-06-14 23:57 ` [PATCH v1 002/107] media: ti-vpe: cal: Avoid function forward declaration Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 003/107] media: ti-vpe: cal: Decouple CSI2 port and CPORT Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 004/107] media: ti-vpe: cal: Index CSI-2 port starting at 0 Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 005/107] media: ti-vpe: cal: Index IRQ registersstarting " Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 006/107] media: ti-vpe: cal: Merge all status variables in IRQ handler Laurent Pinchart
2020-06-16 10:32   ` Tomi Valkeinen
2020-06-16 10:44     ` Laurent Pinchart
2020-06-16 10:49       ` Tomi Valkeinen
2020-06-14 23:58 ` [PATCH v1 007/107] media: ti-vpe: cal: Inline CAL_VERSION macro in its only user Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 008/107] media: ti-vpe: cal: Turn reg_(read|write)_field() into inline functions Laurent Pinchart
2020-06-18 13:29   ` Benoit Parrot
2020-06-19 15:15     ` Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 009/107] media: ti-vpe: cal: Make cal_formats array const Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 010/107] media: ti-vpe: cal: Remove needless variable initialization Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 011/107] media: ti-vpe: cal: Remove needless casts Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 012/107] media: ti-vpe: cal: Turn boolean variable into bool Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 013/107] media: ti-vpe: cal: Make loop indices unsigned where applicable Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 014/107] media: ti-vpe: cal: Embed base_fields array in struct cal_csi2_phy Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 015/107] media: ti-vpe: cal: Don't modify cal_csi2_phy base_fields Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 016/107] media: ti-vpe: cal: Store PHY regmap fields in struct cc_data Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 017/107] media: ti-vpe: cal: Rename cal_csi2_phy base_fields to fields Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 018/107] media: ti-vpe: cal: Make structure fields unsigned where applicable Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 019/107] media: ti-vpe: cal: Constify platform data Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 020/107] media: ti-vpe: cal: Remove static const cal_regmap_config template Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 021/107] media: ti-vpe: cal: Remove unused structure fields Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 022/107] media: ti-vpe: cal: Remove flags field from struct cal_dev Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 023/107] media: ti-vpe: cal: Move function to avoid forward declaration Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 024/107] media: ti-vpe: cal: Rename cc_data to cal_camerarx Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 025/107] media: ti-vpe: cal: Rename cal_csi2_phy to cal_camerarx_data Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 026/107] media: ti-vpe: cal: Name all cal_dev pointers consistently Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 027/107] media: ti-vpe: cal: Name all cal_camerarx " Laurent Pinchart
2020-06-16 10:58   ` Tomi Valkeinen
2020-06-18 14:06   ` Benoit Parrot
2020-06-18 14:15     ` Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 028/107] media: ti-vpe: cal: Remove internal phy structure from cal_camerarx Laurent Pinchart
2020-06-18 14:08   ` Benoit Parrot
2020-06-14 23:58 ` [PATCH v1 029/107] media: ti-vpe: cal: Store instance ID and cal pointer in cal_camerarx Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 030/107] media: ti-vpe: cal: Use dev_* print macros Laurent Pinchart
2020-06-18 18:28   ` Benoit Parrot
2020-06-19 15:22     ` Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 031/107] media: ti-vpe: cal: Add print macros for the cal_camerarx instances Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 032/107] media: ti-vpe: cal: Store sensor-related data in cal_camerarx Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 033/107] media: ti-vpe: cal: Create consistent naming for CAMERARX functions Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 034/107] media: ti-vpe: cal: Group CAMERARX-related functions together Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 035/107] media: ti-vpe: cal: Create consistent naming for context functions Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 036/107] media: ti-vpe: cal: Reorganize remaining code in sections Laurent Pinchart
2020-06-17 10:00   ` Kieran Bingham
2020-06-17 10:02     ` [PATCH] media: ti-vpe: cal: Use cal_data_get_num_csi2_phy() consistently Kieran Bingham
2020-06-17 11:44       ` [PATCH] media: ti-vpe: cal: Handle multiple PHYs Kieran Bingham
2020-06-17 10:51     ` [PATCH v1 036/107] media: ti-vpe: cal: Reorganize remaining code in sections Laurent Pinchart
2020-06-17 10:54       ` Kieran Bingham
2020-06-17 11:01         ` Kieran Bingham
2020-06-17 11:04           ` Laurent Pinchart [this message]
2020-06-17 11:49             ` Kieran Bingham
2020-06-14 23:58 ` [PATCH v1 037/107] media: ti-vpe: cal: Rename cal_ctx.csi2_port to cal_ctx.index Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 038/107] media: ti-vpe: cal: Use correct device name for bus_info Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 039/107] media: ti-vpe: cal: Get struct device without going through v4l2_device Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 040/107] media: ti-vpe: cal: Use ctx_info() instead of v4l2_info() Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 041/107] media: ti-vpe: cal: Use a loop to create CAMERARX and context instances Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 042/107] media: ti-vpe: cal: Drop struct cal_dev v4l2_dev field Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 043/107] media: ti-vpe: cal: Split CAMERARX syscon regmap retrieval to a function Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 044/107] media: ti-vpe: cal: Use syscon_regmap_lookup_by_phandle_args() Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 045/107] media: ti-vpe: cal: Inline cal_get_camerarx_regmap() in caller Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 046/107] media: ti-vpe: cal: Add comments to cal_probe() to delimitate sections Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 047/107] media: ti-vpe: cal: Rename cal_create_instance() to cal_ctx_create() Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 048/107] media: ti-vpe: cal: Hardcode virtual channel to 0 Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 049/107] media: ti-vpe: cal: Use of_graph_get_endpoint_by_regs() to parse OF Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 050/107] media: ti-vpe: cal: Fix usage of v4l2_fwnode_endpoint_parse() Laurent Pinchart
2020-06-16 11:28   ` Tomi Valkeinen
2020-06-14 23:58 ` [PATCH v1 051/107] media: ti-vpe: cal: Decouple control handler from v4l2_device Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 052/107] media: ti-vpe: cal: Move v4l2_device from cal_ctx to cal_dev Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 053/107] media: ti-vpe: cal: Split video device initialization and registration Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 054/107] media: ti-vpe: cal: Add context V4L2 cleanup and unregister functions Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 055/107] media: ti-vpe: cal: Unregister video device before cleanup Laurent Pinchart
2020-06-23 11:01   ` Tomi Valkeinen
2020-06-14 23:58 ` [PATCH v1 056/107] media: ti-vpe: cal: Add cal_camerarx_destroy() to cleanup CAMERARX Laurent Pinchart
2020-06-17 10:43   ` Kieran Bingham
2020-06-19 15:36     ` Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 057/107] media: ti-vpe: cal: Move DT parsing to CAMERARX Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 058/107] media: ti-vpe: cal: Use ARRAY_SIZE to replace numerical value Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 059/107] media: ti-vpe: cal: Move all sensor-related init to .bound() notifier Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 060/107] media: ti-vpe: cal: Allow multiple contexts per subdev notifier Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 061/107] media: ti-vpe: cal: Move async notifiers from contexts to cal_dev Laurent Pinchart
2020-06-14 23:58 ` [PATCH v1 062/107] media: ti-vpe: cal: Replace context with phy in async notifier entries Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 063/107] media: ti-vpe: cal: Operate on phy instances in cal_quickdump_regs() Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 064/107] media: ti-vpe: cal: Decouple context and phy cleanup at remove time Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 065/107] media: ti-vpe: cal: Move CAL_NUM_CSI2_PORTS from cal_regs.h to cal.c Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 066/107] media: ti-vpe: cal: Remove isvcirqset() and isportirqset() macros Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 067/107] media: ti-vpe: cal: Replace number of ports numerical value by macro Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 068/107] media: ti-vpe: cal: Split media initialization and cleanup to functions Laurent Pinchart
2020-06-18 19:17   ` Benoit Parrot
2020-06-14 23:59 ` [PATCH v1 069/107] media: ti-vpe: cal: Read hardware revision earlier during probe Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 070/107] media: ti-vpe: cal: Print revision and hwinfo in a more readable format Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 071/107] media: ti-vpe: cal: Store struct device in cal_dev Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 072/107] media: ti-vpe: cal: Register a media device Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 073/107] media: ti-vpe: cal: Init formats in cal_ctx_v4l2_register() Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 074/107] media: ti-vpe: cal: Allocate cal_ctx active_fmt array dynamically Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 075/107] media: ti-vpe: cal: Inline cal_camerarx_max_lanes() in its only caller Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 076/107] media: ti-vpe: cal: Reorder camerarx functions to prepare refactoring Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 077/107] media: ti-vpe: cal: Refactor camerarx start and stop Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 078/107] media: ti-vpe: cal: Don't store external rate in cal_camerarx Laurent Pinchart
2020-06-17  9:56   ` Kieran Bingham
2020-06-17 10:05     ` Laurent Pinchart
2020-06-17 10:16       ` Kieran Bingham
2020-06-18  2:36         ` Laurent Pinchart
2020-06-18  8:07           ` Kieran Bingham
2020-06-14 23:59 ` [PATCH v1 079/107] media: ti-vpe: cal: Remove unneeded phy->sensor NULL check Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 080/107] media: ti-vpe: cal: Use 'unsigned int' type instead of 'unsigned' Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 081/107] media: ti-vpe: cal: Split video node handling to cal-video.c Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 082/107] media: ti-vpe: cal: Move CAL I/O accessors to cal.h Laurent Pinchart
2020-06-15  2:50   ` kernel test robot
2020-06-19  4:18   ` Ezequiel Garcia
2020-06-19 15:40     ` Laurent Pinchart
2020-06-19 17:18       ` Benoit Parrot
2020-06-14 23:59 ` [PATCH v1 083/107] media: ti-vpe: cal: Split CAMERARX handling to cal-camerarx.c Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 084/107] media: ti-vpe: cal: Create subdev for CAMERARX Laurent Pinchart
2020-06-17 10:10   ` Kieran Bingham
2020-06-19 15:52     ` Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 085/107] media: ti-vpe: cal: Drop cal_ctx m_fmt field Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 086/107] media: ti-vpe: cal: Move format handling to cal.c and expose helpers Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 087/107] media: ti-vpe: cal: Rename MAX_(WIDTH|HEIGHT)_* macros with CAL_ prefix Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 088/107] media: ti-vpe: cal: Replace hardcoded BIT() value with macro Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 089/107] media: ti-vpe: cal: Iterate over correct number of CAMERARX instances Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 090/107] media: ti-vpe: cal: Implement subdev ops for CAMERARX Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 091/107] media: ti-vpe: cal: Use CAMERARX subdev s_stream op in video device code Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 092/107] media: ti-vpe: cal: Don't pass format to cal_ctx_wr_dma_config() Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 093/107] media: ti-vpe: cal: Rename struct cal_fmt to cal_format_info Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 094/107] media: ti-vpe: cal: Refactor interrupt enable/disable Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 095/107] media: ti-vpe: cal: Fold PPI enable in CAMERARX .s_stream() Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 096/107] media: ti-vpe: cal: Stop write DMA without disabling PPI Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 097/107] media: ti-vpe: cal: Use spin_lock_irq() when starting or stopping stream Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 098/107] media: ti-vpe: cal: Share buffer release code between start and stop Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 099/107] media: ti-vpe: cal: Drop V4L2_CAP_READWRITE Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 100/107] media: ti-vpe: cal: Drop unneeded check in cal_calc_format_size() Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 101/107] media: ti-vpe: cal: Remove DMA queue empty check at start streaming time Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 102/107] media: ti-vpe: cal: Use list_first_entry() Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 103/107] media: ti-vpe: cal: Group all DMA queue fields in struct cal_dmaqueue Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 104/107] media: ti-vpe: cal: Set cal_dmaqueue.pending to NULL when no pending buffer Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 105/107] media: ti-vpe: cal: Store buffer DMA address in dma_addr_t Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 106/107] media: ti-vpe: cal: Simplify the context API Laurent Pinchart
2020-06-14 23:59 ` [PATCH v1 107/107] media: ti-vpe: cal: Implement media controller centric API Laurent Pinchart
2020-06-19 14:46   ` Benoit Parrot
2020-06-19 15:58     ` Laurent Pinchart
2020-06-16 11:43 ` [PATCH v1 000/107] media: ti-vpe: cal: Add media controller support Tomi Valkeinen
2020-06-19 17:04   ` Laurent Pinchart
2020-06-19 14:53 ` Benoit Parrot
2020-06-19 14:57   ` Benoit Parrot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200617110459.GD5838@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=bparrot@ti.com \
    --cc=kieran.bingham@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=tomi.valkeinen@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox