From: g.liakhovetski@gmx.de (Guennadi Liakhovetski)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 12/13] atmel-isi: use union for the fbd (frame buffer descriptor)
Date: Sun, 24 Jan 2016 20:31:41 +0100 (CET) [thread overview]
Message-ID: <Pine.LNX.4.64.1601241931430.16570@axis700.grange> (raw)
In-Reply-To: <1453121545-27528-8-git-send-email-rainyfeeling@gmail.com>
On Mon, 18 Jan 2016, Josh Wu wrote:
> From: Josh Wu <josh.wu@atmel.com>
>
> This way, we can easy to add other type of fbd for new hardware.
Ok, I've applied all your 13 patches to check, what the resulting driver
would look like. To me it looks like you really abstract away _everything_
remotely hardware-specific. What is left is yet another abstraction layer,
into which you can pack a wide range of hardware types, which are very
different from the original ISI. I mean, you could probably pack - to some
extent, maybe sacrificing some features - other existing soc-camera
drivers, like MX3, MX2, CEU,... - essentially those, using VB2. And I
don't think that's a good idea. We have a class of V4L2 camera bridge
drivers, that's fine. They use all the standard APIs to connect to the
user-space and to other V4L2 drivers in video pipelines - V4L2 ioctl()s,
subdev, Media Controller, VB2, V4L2 control API etc. Under that we have
soc-camera - mainly for a few existing bridge drivers, because it takes a
part of bridge driver's implementation freedom away and many or most
modern camera bridge interfaces are more complex, than what soc-camera
currently supports, and extending it makes little sense, it is just more
logical to create a full-features V4L2 bridge driver with a full access to
all relevant APIs. With your patches #12 and #13 you seem to be creating
an even tighter, narrower API for very thin drivers. That just provide a
couple of hardware-related functions and create a V4L2 bridge driver from
that. What kind of hardware is that new controller, that you'd like to
support by the same driver? Wouldn't it be better to create a new driver
for it? Is it really similar to the ISI controller?
Thanks
Guennadi
>
> Signed-off-by: Josh Wu <rainyfeeling@gmail.com>
> ---
>
> drivers/media/platform/soc_camera/atmel-isi.c | 33 ++++++++++++++++++---------
> 1 file changed, 22 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/media/platform/soc_camera/atmel-isi.c b/drivers/media/platform/soc_camera/atmel-isi.c
> index 7d2e952..b4c1f38 100644
> --- a/drivers/media/platform/soc_camera/atmel-isi.c
> +++ b/drivers/media/platform/soc_camera/atmel-isi.c
> @@ -37,7 +37,7 @@
> #define FRAME_INTERVAL_MILLI_SEC (1000 / MIN_FRAME_RATE)
>
> /* Frame buffer descriptor */
> -struct fbd {
> +struct fbd_isi_v2 {
> /* Physical address of the frame buffer */
> u32 fb_address;
> /* DMA Control Register(only in HISI2) */
> @@ -46,9 +46,13 @@ struct fbd {
> u32 next_fbd_address;
> };
>
> +union fbd {
> + struct fbd_isi_v2 fbd_isi;
> +};
> +
> struct isi_dma_desc {
> struct list_head list;
> - struct fbd *p_fbd;
> + union fbd *p_fbd;
> dma_addr_t fbd_phys;
> };
>
> @@ -69,7 +73,7 @@ struct atmel_isi {
> struct vb2_alloc_ctx *alloc_ctx;
>
> /* Allocate descriptors for dma buffer use */
> - struct fbd *p_fb_descriptors;
> + union fbd *p_fb_descriptors;
> dma_addr_t fb_descriptors_phys;
> struct list_head dma_desc_head;
> struct isi_dma_desc dma_desc[MAX_BUFFER_NUM];
> @@ -396,6 +400,16 @@ static int buffer_init(struct vb2_buffer *vb)
> return 0;
> }
>
> +static void isi_hw_init_dma_desc(union fbd *p_fdb, u32 fb_addr,
> + u32 next_fbd_addr)
> +{
> + struct fbd_isi_v2 *p = &(p_fdb->fbd_isi);
Superfluous parentheses
> +
> + p->fb_address = fb_addr;
> + p->next_fbd_address = next_fbd_addr;
> + p->dma_ctrl = ISI_DMA_CTRL_WB;
> +}
> +
> static int buffer_prepare(struct vb2_buffer *vb)
> {
> struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
> @@ -428,10 +442,7 @@ static int buffer_prepare(struct vb2_buffer *vb)
> list_del_init(&desc->list);
>
> /* Initialize the dma descriptor */
> - desc->p_fbd->fb_address =
> - vb2_dma_contig_plane_dma_addr(vb, 0);
> - desc->p_fbd->next_fbd_address = 0;
> - desc->p_fbd->dma_ctrl = ISI_DMA_CTRL_WB;
> + isi_hw_init_dma_desc(desc->p_fbd, vb2_dma_contig_plane_dma_addr(vb, 0), 0);
>
> buf->p_dma_desc = desc;
> }
> @@ -923,7 +934,7 @@ static int atmel_isi_remove(struct platform_device *pdev)
> soc_camera_host_unregister(soc_host);
> vb2_dma_contig_cleanup_ctx(isi->alloc_ctx);
> dma_free_coherent(&pdev->dev,
> - sizeof(struct fbd) * MAX_BUFFER_NUM,
> + sizeof(union fbd) * MAX_BUFFER_NUM,
> isi->p_fb_descriptors,
> isi->fb_descriptors_phys);
> pm_runtime_disable(&pdev->dev);
> @@ -1010,7 +1021,7 @@ static int atmel_isi_probe(struct platform_device *pdev)
> INIT_LIST_HEAD(&isi->dma_desc_head);
>
> isi->p_fb_descriptors = dma_alloc_coherent(&pdev->dev,
> - sizeof(struct fbd) * MAX_BUFFER_NUM,
> + sizeof(union fbd) * MAX_BUFFER_NUM,
> &isi->fb_descriptors_phys,
> GFP_KERNEL);
> if (!isi->p_fb_descriptors) {
> @@ -1021,7 +1032,7 @@ static int atmel_isi_probe(struct platform_device *pdev)
> for (i = 0; i < MAX_BUFFER_NUM; i++) {
> isi->dma_desc[i].p_fbd = isi->p_fb_descriptors + i;
> isi->dma_desc[i].fbd_phys = isi->fb_descriptors_phys +
> - i * sizeof(struct fbd);
> + i * sizeof(union fbd);
> list_add(&isi->dma_desc[i].list, &isi->dma_desc_head);
> }
>
> @@ -1080,7 +1091,7 @@ err_ioremap:
> vb2_dma_contig_cleanup_ctx(isi->alloc_ctx);
> err_alloc_ctx:
> dma_free_coherent(&pdev->dev,
> - sizeof(struct fbd) * MAX_BUFFER_NUM,
> + sizeof(union fbd) * MAX_BUFFER_NUM,
> isi->p_fb_descriptors,
> isi->fb_descriptors_phys);
>
> --
> 1.9.1
>
next prev parent reply other threads:[~2016-01-24 19:31 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-18 12:21 [PATCH 00/13] media: atmel-isi: extract the hw releated functions into structure Josh Wu
2016-01-18 12:21 ` [PATCH 01/13] atmel-isi: use try_or_set_fmt() for both set_fmt() and try_fmt() Josh Wu
2016-01-24 16:11 ` Guennadi Liakhovetski
2016-01-18 12:21 ` [PATCH 02/13] atmel-isi: move the is_support() close to try/set format function Josh Wu
2016-01-24 16:12 ` Guennadi Liakhovetski
2016-01-18 12:21 ` [PATCH 03/13] atmel-isi: add isi_hw_initialize() function to handle hw setup Josh Wu
2016-01-18 12:21 ` [PATCH 04/13] atmel-isi: move the cfg1 initialize to isi_hw_initialize() Josh Wu
2016-01-18 12:21 ` [PATCH 05/13] atmel-isi: add a function: isi_hw_wait_status() to check ISI_SR status Josh Wu
2016-01-18 12:52 ` [PATCH 06/13] atmel-isi: check ISI_SR's flags by polling instead of interrupt Josh Wu
2016-01-18 12:52 ` [PATCH 07/13] atmel-isi: move hw code into isi_hw_initialize() Josh Wu
2016-01-24 18:09 ` Guennadi Liakhovetski
2016-01-26 14:07 ` Josh Wu
2016-01-18 12:52 ` [PATCH 08/13] atmel-isi: remove the function set_dma_ctrl() as it just use once Josh Wu
2016-01-18 12:52 ` [PATCH 09/13] atmel-isi: add a function start_isi() Josh Wu
2016-01-18 12:52 ` [PATCH 10/13] atmel-isi: reuse start_dma() function in isi interrupt handler Josh Wu
2016-01-18 12:52 ` [PATCH 11/13] atmel-isi: add hw_uninitialize() in stop_streaming() Josh Wu
2016-01-18 12:52 ` [PATCH 11/13] atmel-isi: add hw_uninitialize() Josh Wu
2016-01-18 12:52 ` [PATCH 12/13] atmel-isi: use union for the fbd (frame buffer descriptor) Josh Wu
2016-01-24 19:31 ` Guennadi Liakhovetski [this message]
2016-01-26 14:04 ` Josh Wu
2016-01-26 14:10 ` Guennadi Liakhovetski
2016-01-26 14:24 ` Josh Wu
2016-01-26 14:39 ` Guennadi Liakhovetski
2016-01-18 12:52 ` [PATCH 13/13] atmel-isi: use an hw_data structure according compatible string Josh Wu
2016-01-24 16:58 ` [PATCH 06/13] atmel-isi: check ISI_SR's flags by polling instead of interrupt Guennadi Liakhovetski
2016-01-26 14:16 ` Josh Wu
2016-01-26 14:38 ` Guennadi Liakhovetski
2016-01-19 14:52 ` [PATCH 00/13] media: atmel-isi: extract the hw releated functions into structure Ludovic Desroches
2016-01-21 14:19 ` Josh Wu
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=Pine.LNX.4.64.1601241931430.16570@axis700.grange \
--to=g.liakhovetski@gmx.de \
--cc=linux-arm-kernel@lists.infradead.org \
/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